:root {
  color-scheme: light;
  --bg: #f3f5f7;
  --surface: #ffffff;
  --surface-2: #eef2f5;
  --ink: #17212b;
  --muted: #627282;
  --line: #d8e0e7;
  --accent: #0f766e;
  --accent-2: #d97706;
  --danger: #b42318;
  --shadow: 0 18px 50px rgba(23, 33, 43, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  display: grid;
  min-height: 100vh;
  margin: 0;
  grid-template-rows: 1fr auto;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.08), transparent 34%),
    linear-gradient(315deg, rgba(217, 119, 6, 0.08), transparent 30%),
    var(--bg);
  color: var(--ink);
  font-family: "Inconsolata", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.app {
  align-self: start;
}

button,
a.primary-action,
input,
textarea {
  font: inherit;
}

.app {
  width: min(1280px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.menu-view {
  padding-top: clamp(24px, 8vh, 84px);
}

.seo-page {
  display: grid;
  gap: 20px;
  max-width: 860px;
}

.seo-page .primary-action {
  width: fit-content;
  padding: 0 18px;
}

.site-footer {
  display: flex;
  width: min(1280px, calc(100% - 32px));
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 0 auto;
  padding: 18px 0 28px;
  color: var(--muted);
  font-size: 0.9rem;
}

.site-footer nav {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.site-footer a {
  color: var(--muted);
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--ink);
}

.menu-hero {
  max-width: 780px;
}

.menu-copy {
  max-width: 620px;
  margin-top: 16px;
  color: var(--muted);
  font-size: clamp(1.05rem, 2vw, 1.35rem);
  line-height: 1.45;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
  margin-top: 34px;
}

.tool-card {
  display: flex;
  min-height: 240px;
  flex-direction: column;
  justify-content: space-between;
  gap: 24px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.tool-card h2 {
  margin-top: 18px;
  font-size: 1.55rem;
}

.tool-card p {
  margin-top: 10px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.45;
}

.typing-page {
  display: grid;
  gap: 18px;
  max-width: 1120px;
}

.typing-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
}

.typing-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.typing-stats {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.typing-panel {
  padding: 18px;
}

.typing-status {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
  text-transform: uppercase;
}

.typing-prompt {
  min-height: 220px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--ink);
  font-size: clamp(1.15rem, 1.8vw, 1.38rem);
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.typing-char {
  display: inline;
}

.typing-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
}

.typing-modal[hidden] {
  display: none;
}

.typing-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(23, 33, 43, 0.52);
  backdrop-filter: blur(3px);
}

.typing-modal-card {
  position: relative;
  z-index: 1;
  width: min(920px, calc(100vw - 24px));
  max-height: min(88vh, 880px);
  overflow: auto;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 30px 90px rgba(23, 33, 43, 0.24);
}

.typing-results-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.typing-chart-wrap {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  overflow: hidden;
}

.typing-chart-wrap canvas {
  display: block;
  width: 100%;
}

.typing-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}

.typing-char {
  padding: 0 1px;
  border-radius: 4px;
}

.typing-char.correct {
  color: #0b5f59;
  background: rgba(15, 118, 110, 0.12);
}

.typing-char.incorrect {
  color: #991b1b;
  background: rgba(180, 35, 24, 0.12);
}

.typing-char.current {
  background: rgba(15, 118, 110, 0.08);
  box-shadow: inset 0 -2px 0 var(--accent);
}

.typing-char.overflow {
  background: rgba(180, 35, 24, 0.18);
}

.typing-input {
  width: 100%;
  min-height: 128px;
  margin-top: 14px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  line-height: 1.5;
  resize: vertical;
}

.typing-input:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.12);
}

.tool-card.disabled {
  opacity: 0.62;
}

.tool-icon {
  display: inline-flex;
  width: 48px;
  height: 48px;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(15, 118, 110, 0.28);
  border-radius: 8px;
  background: #e8f6f4;
  color: #0b4f4a;
  font-size: 1.8rem;
  font-weight: 900;
}

.primary-action {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.primary-action:hover {
  border-color: #0b5f59;
  background: #0b5f59;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: end;
  padding: 10px 0 22px;
}

.back-button {
  margin-bottom: 16px;
}

.eyebrow,
.label {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  margin-top: 4px;
  font-size: clamp(2rem, 5vw, 4.8rem);
  line-height: 0.98;
  letter-spacing: 0;
}

h2 {
  font-size: 1.08rem;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(96px, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
  box-shadow: var(--shadow);
}

.status-strip > div {
  min-width: 0;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.9);
}

.status-strip strong {
  display: block;
  overflow: hidden;
  margin-top: 4px;
  font-size: 1.25rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.panel,
.keyboard-shell {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.live-panel {
  padding: 18px;
}

.panel-head {
  display: flex;
  gap: 18px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.panel-head p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.92rem;
}

.panel-head.compact {
  margin-bottom: 12px;
}

.actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

button,
a.primary-action {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font-weight: 750;
  text-decoration: none;
}

button:hover,
a.primary-action:hover {
  border-color: #aab8c4;
  background: #f8fafb;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.72;
}

button span {
  font-size: 1.2rem;
  line-height: 1;
}

.mode-toggle {
  position: relative;
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(74px, 1fr));
  gap: 0;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
}

.mode-thumb {
  position: absolute;
  top: 2px;
  bottom: 2px;
  left: 2px;
  width: calc(50% - 2px);
  border-radius: 999px;
  background: var(--ink);
  box-shadow: 0 4px 14px rgba(23, 33, 43, 0.18);
  transition: transform 180ms ease;
}

.mode-toggle.mode-mac .mode-thumb {
  transform: translateX(100%);
}

.mode-button {
  position: relative;
  z-index: 1;
  min-height: 34px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  transition: color 180ms ease;
}

.mode-button:hover {
  border-color: transparent;
  background: transparent;
  color: var(--ink);
}

.mode-button.active {
  color: #ffffff;
}

.mode-button.active:hover {
  color: #ffffff;
}

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

.mouse-readout {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.readout {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.readout span {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.readout strong {
  display: block;
  overflow-wrap: anywhere;
  margin-top: 6px;
  font-size: 1.12rem;
}

.fps-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(160px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.fps-controls label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 850;
  text-transform: uppercase;
}

.fps-controls input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  padding: 0 12px;
  font-size: 1.15rem;
  font-weight: 850;
}

.audio-actions {
  display: grid;
  grid-template-columns: repeat(5, minmax(96px, 1fr));
  gap: 8px;
}

.audio-actions button.active {
  border-color: var(--accent);
  background: #e8f6f4;
  color: #0b4f4a;
}

.audio-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.audio-controls label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
  text-transform: uppercase;
}

.audio-controls input {
  width: 100%;
  accent-color: var(--accent);
}

.audio-layout {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(320px, 1fr);
  gap: 18px;
  margin-top: 18px;
}

.audio-panel {
  min-width: 0;
  padding: 16px;
}

.audio-meter {
  display: grid;
  gap: 14px;
}

.audio-channel {
  display: grid;
  gap: 8px;
}

.audio-channel span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
  text-transform: uppercase;
}

.audio-bar {
  height: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
}

.audio-bar > div {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #23a79d, #0f766e);
  transition: width 120ms ease;
}

.audio-checks {
  display: grid;
  gap: 10px;
}

.audio-checks > div {
  display: grid;
  gap: 3px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.audio-checks strong {
  font-size: 1.02rem;
}

.audio-checks span {
  color: var(--muted);
}

.keyboard-shell {
  margin-top: 18px;
  padding: 16px;
  overflow-x: auto;
}

.mouse-layout {
  display: grid;
  grid-template-columns: minmax(420px, 1.4fr) minmax(280px, 0.6fr);
  gap: 18px;
  margin-top: 18px;
}

.mouse-panel,
.mouse-log-panel {
  padding: 16px;
}

#mouse-pad-panel:fullscreen {
  display: grid;
  padding: 18px;
  border: 0;
  border-radius: 0;
  background: var(--surface);
}

#mouse-pad-panel:fullscreen .mouse-pad {
  min-height: calc(100vh - 36px);
}

#mouse-pad-panel.fullscreen-fallback {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  padding: 18px;
  border: 0;
  border-radius: 0;
  background: var(--surface);
}

#mouse-pad-panel.fullscreen-fallback .mouse-pad {
  min-height: calc(100vh - 36px);
}

.mouse-pad {
  position: relative;
  display: grid;
  min-height: 430px;
  place-items: center;
  overflow: hidden;
  border: 1px dashed #9badb9;
  border-radius: 8px;
  background:
    linear-gradient(rgba(15, 118, 110, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 118, 110, 0.08) 1px, transparent 1px),
    #fbfcfd;
  background-size: 28px 28px;
  color: var(--muted);
  font-size: 1.4rem;
  font-weight: 850;
  user-select: none;
}

.mouse-pad-action {
  position: absolute;
  z-index: 3;
  top: 14px;
  right: 14px;
  width: 42px;
  min-height: 42px;
  padding: 0;
  font-size: 1.35rem;
}

.mouse-pad-overlay {
  position: absolute;
  z-index: 2;
  top: 14px;
  left: 14px;
  display: none;
  grid-template-columns: repeat(4, minmax(84px, 1fr));
  gap: 8px;
  width: min(680px, calc(100% - 180px));
  color: var(--ink);
  font-size: 0.9rem;
  pointer-events: none;
}

#mouse-pad-panel:fullscreen .mouse-pad-overlay,
#mouse-pad-panel.fullscreen-fallback .mouse-pad-overlay {
  display: grid;
}

.mouse-pad-overlay > div {
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid rgba(216, 224, 231, 0.86);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 8px 20px rgba(23, 33, 43, 0.08);
}

.mouse-pad-overlay span,
.mouse-pad-overlay strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mouse-pad-overlay span {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
}

.mouse-pad-overlay strong {
  margin-top: 3px;
  font-size: 1rem;
}

.mouse-pad.active {
  border-color: var(--accent);
}

.mouse-cursor {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 16px;
  height: 16px;
  border: 2px solid var(--accent);
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.14);
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.mouse-buttons {
  display: grid;
  gap: 10px;
}

.mouse-button {
  display: flex;
  min-height: 52px;
  align-items: center;
  justify-content: space-between;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 0 14px;
  font-weight: 850;
}

.mouse-button::after {
  content: "Idle";
  color: var(--muted);
  font-size: 0.9rem;
}

.mouse-button.pressed {
  border-color: var(--accent);
  background: #e8f6f4;
  color: #0b4f4a;
}

.mouse-button.pressed::after {
  content: "Pressed";
  color: #0b4f4a;
}

.mouse-log-panel {
  margin-top: 18px;
}

.pattern-controls {
  display: grid;
  grid-template-columns: repeat(5, minmax(96px, 1fr));
  gap: 8px;
}

.pattern-button.active {
  border-color: var(--accent);
  background: #e8f6f4;
  color: #0b4f4a;
}

.display-stage-panel {
  margin-top: 18px;
  padding: 16px;
}

.display-stage-panel:fullscreen {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: #000000;
}

.display-stage-panel.fullscreen-fallback {
  position: fixed;
  inset: 0;
  z-index: 30;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: #000000;
}

.display-stage {
  position: relative;
  min-height: 520px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.display-stage-action {
  position: absolute;
  z-index: 3;
  top: 14px;
  right: 14px;
  width: 42px;
  min-height: 42px;
  padding: 0;
  font-size: 1.35rem;
}

.display-nav {
  position: absolute;
  z-index: 3;
  top: 50%;
  width: 50px;
  min-height: 70px;
  padding: 0;
  border-color: rgba(216, 224, 231, 0.7);
  background: rgba(255, 255, 255, 0.82);
  font-size: 2.2rem;
  transform: translateY(-50%);
}

.display-nav:hover {
  background: rgba(255, 255, 255, 0.94);
}

.display-nav-prev {
  left: 14px;
}

.display-nav-next {
  right: 14px;
}

.display-stage-panel:fullscreen .display-stage,
.display-stage-panel.fullscreen-fallback .display-stage {
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  border: 0;
  border-radius: 0;
}

.display-overlay {
  position: absolute;
  top: 14px;
  left: 14px;
  display: grid;
  gap: 2px;
  max-width: min(420px, calc(100% - 28px));
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(23, 33, 43, 0.72);
  color: #ffffff;
  font-size: 0.9rem;
  pointer-events: none;
}

.display-overlay strong {
  font-size: 1.05rem;
}

.display-overlay span {
  color: rgba(255, 255, 255, 0.78);
}

.pattern-white {
  background: #ffffff;
}

.pattern-black {
  background: #000000;
}

.pattern-red {
  background: #ff0000;
}

.pattern-green {
  background: #00ff00;
}

.pattern-blue {
  background: #0000ff;
}

.pattern-gray {
  background: #808080;
}

.pattern-gradient {
  background: linear-gradient(90deg, #000000, #ffffff);
}

.pattern-grid {
  background:
    linear-gradient(#000000 1px, transparent 1px),
    linear-gradient(90deg, #000000 1px, transparent 1px),
    #ffffff;
  background-size: 32px 32px;
}

.pattern-checker {
  background:
    linear-gradient(45deg, #000000 25%, transparent 25%),
    linear-gradient(-45deg, #000000 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #000000 75%),
    linear-gradient(-45deg, transparent 75%, #000000 75%),
    #ffffff;
  background-position: 0 0, 0 16px, 16px -16px, -16px 0;
  background-size: 32px 32px;
}

.pattern-contrast {
  background:
    linear-gradient(90deg,
      #000000 0 10%,
      #1c1c1c 10% 20%,
      #383838 20% 30%,
      #555555 30% 40%,
      #717171 40% 50%,
      #8e8e8e 50% 60%,
      #aaaaaa 60% 70%,
      #c7c7c7 70% 80%,
      #e3e3e3 80% 90%,
      #ffffff 90% 100%);
}

.refresh-stage-panel {
  margin-top: 18px;
  padding: 16px;
}

.refresh-stage-panel:fullscreen {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: #08111a;
}

.refresh-stage-panel.fullscreen-fallback {
  position: fixed;
  inset: 0;
  z-index: 30;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: #08111a;
}

.refresh-stage {
  position: relative;
  min-height: 520px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.06) 1px, transparent 1px),
    #08111a;
  background-size: 36px 36px;
}

.refresh-stage-panel:fullscreen .refresh-stage,
.refresh-stage-panel.fullscreen-fallback .refresh-stage {
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  border: 0;
  border-radius: 0;
}

.refresh-stage-action {
  position: absolute;
  z-index: 4;
  top: 14px;
  right: 14px;
  width: 42px;
  min-height: 42px;
  padding: 0;
  font-size: 1.35rem;
}

.refresh-overlay {
  position: absolute;
  z-index: 3;
  top: 14px;
  left: 14px;
  display: none;
  grid-template-columns: repeat(4, minmax(92px, 1fr));
  gap: 8px;
  width: min(620px, calc(100% - 76px));
  pointer-events: none;
}

.refresh-stage-panel:fullscreen .refresh-overlay,
.refresh-stage-panel.fullscreen-fallback .refresh-overlay {
  display: grid;
}

.refresh-overlay > div {
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid rgba(216, 224, 231, 0.25);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.refresh-overlay span,
.refresh-overlay strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.refresh-overlay span {
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.74rem;
  font-weight: 850;
  text-transform: uppercase;
}

.refresh-overlay strong {
  margin-top: 3px;
  font-size: 1.02rem;
}

.motion-lanes {
  position: absolute;
  top: 50%;
  left: 48px;
  right: 48px;
  display: grid;
  gap: 18px;
  transform: translateY(-50%);
}

.motion-lane {
  position: relative;
  height: 96px;
  border-top: 1px solid rgba(255, 255, 255, 0.22);
  border-bottom: 1px solid rgba(255, 255, 255, 0.22);
}

.lane-label {
  position: absolute;
  left: 0;
  top: -3px;
  display: grid;
  min-width: 110px;
  padding: 8px 10px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  transform: translateY(-100%);
}

.lane-label span {
  color: rgba(255, 255, 255, 0.68);
  font-size: 0.72rem;
  font-weight: 850;
  text-transform: uppercase;
}

.lane-label strong {
  margin-top: 2px;
  font-size: 1rem;
}

.refresh-target {
  position: absolute;
  top: 50%;
  left: 0;
  display: grid;
  width: 86px;
  height: 54px;
  place-items: center;
  border: 2px solid #ffffff;
  border-radius: 8px;
  background: #23a79d;
  color: #ffffff;
  box-shadow: 0 0 0 5px rgba(35, 167, 157, 0.2);
  font-size: 1.35rem;
  font-weight: 900;
  transform: translate(0, -50%);
  will-change: transform;
}

.refresh-target-a {
  background: #d97706;
  box-shadow: 0 0 0 5px rgba(217, 119, 6, 0.2);
}

.refresh-target-b {
  background: #8b5cf6;
  box-shadow: 0 0 0 5px rgba(139, 92, 246, 0.22);
}

.motion-ruler {
  position: absolute;
  left: 48px;
  right: 48px;
  bottom: 42px;
  height: 32px;
  background:
    repeating-linear-gradient(90deg,
      rgba(255, 255, 255, 0.8) 0 2px,
      transparent 2px 40px);
  opacity: 0.5;
}

.keyboard {
  display: grid;
  grid-template-columns: 760px 156px 208px;
  grid-template-areas:
    "fn fn fn"
    "typing nav numpad"
    "typing arrows numpad";
  align-items: start;
  min-width: 1160px;
  gap: 14px 18px;
}

.keyboard-section {
  display: grid;
  gap: 8px;
}

.function-row {
  grid-area: fn;
  display: grid;
  grid-template-columns: 760px 156px 208px;
  gap: 18px;
}

.typing-section {
  grid-area: typing;
}

.function-typing {
  min-width: 0;
}

.function-system {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.function-numpad {
  min-width: 0;
}

.nav-section {
  grid-area: nav;
  grid-template-columns: repeat(3, 1fr);
}

.arrow-section {
  grid-area: arrows;
  grid-template-columns: repeat(3, 1fr);
  align-self: end;
  margin-top: 62px;
}

.numpad-section {
  grid-area: numpad;
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: 54px;
}

.key-row {
  display: grid;
  grid-template-columns: repeat(30, minmax(0, 1fr));
  gap: 8px;
}

.function-row .key-row {
  grid-template-columns: repeat(30, minmax(0, 1fr));
}

.key {
  position: relative;
  display: flex;
  min-width: 0;
  height: 54px;
  grid-column: span var(--w, 2);
  grid-row: span var(--h, 1);
  flex-direction: column;
  justify-content: space-between;
  padding: 8px;
  border: 1px solid #cbd5df;
  border-radius: 7px;
  background: linear-gradient(#ffffff, #edf2f6);
  color: var(--ink);
  box-shadow: inset 0 -2px 0 rgba(23, 33, 43, 0.08);
  transition: transform 90ms ease, border-color 90ms ease, background 90ms ease;
}

.numpad-section .key,
.nav-section .key,
.function-system .key,
.arrow-section .key {
  grid-column: span var(--w, 1);
  height: auto;
  min-height: 54px;
}

.key-spacer {
  grid-column: span var(--w, 1);
  min-height: 54px;
}

.key .main {
  overflow: hidden;
  font-weight: 800;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.key .code {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.66rem;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.key.pressed {
  border-color: #0f766e;
  background: linear-gradient(#23a79d, #0f766e);
  color: #ffffff;
  transform: translateY(2px);
  box-shadow: inset 0 2px 0 rgba(0, 0, 0, 0.16);
}

.key.pressed .code {
  color: rgba(255, 255, 255, 0.78);
}

.key.seen:not(.pressed) {
  border-color: rgba(217, 119, 6, 0.55);
  background: linear-gradient(#fff7ed, #fde7c7);
}

.lower-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.8fr) minmax(360px, 1.2fr);
  gap: 18px;
  margin-top: 18px;
}

.lower-grid .panel {
  min-width: 0;
  padding: 16px;
}

.chip-list {
  display: flex;
  min-height: 112px;
  align-content: flex-start;
  gap: 8px;
  flex-wrap: wrap;
}

.chip-list.empty {
  align-items: center;
  color: var(--muted);
}

.chip {
  display: inline-flex;
  height: 34px;
  align-items: center;
  border: 1px solid rgba(15, 118, 110, 0.28);
  border-radius: 999px;
  background: #e8f6f4;
  padding: 0 12px;
  color: #0b4f4a;
  font-size: 0.9rem;
  font-weight: 800;
}

.event-log {
  display: grid;
  max-height: 276px;
  margin: 0;
  padding: 0;
  gap: 6px;
  overflow: auto;
  list-style: none;
}

.event-log li {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr) minmax(120px, 0.6fr);
  gap: 10px;
  align-items: center;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcfd;
  font-size: 0.88rem;
}

.event-type {
  font-weight: 900;
}

.event-type.down {
  color: var(--accent);
}

.event-type.up {
  color: var(--danger);
}

.event-code,
.event-key {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.event-code {
  color: var(--muted);
}

@media (max-width: 820px) {
  .app {
    width: min(100% - 20px, 1280px);
    padding-top: 16px;
  }

  .site-footer {
    width: min(100% - 20px, 1280px);
    align-items: flex-start;
    flex-direction: column;
  }

  .hero,
  .audio-layout,
  .audio-controls,
  .lower-grid,
  .mouse-layout,
  .pattern-controls,
  .tool-grid {
    grid-template-columns: 1fr;
  }

  .status-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .status-strip > div {
    padding: 12px 10px;
  }

  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .typing-hero {
    align-items: flex-start;
    flex-direction: column;
  }

  .typing-actions {
    justify-content: flex-start;
  }

  .typing-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .typing-results-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .readout-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .event-log li {
    grid-template-columns: 68px minmax(0, 1fr);
  }

  .event-code {
    grid-column: 2;
  }
}

@media (max-width: 520px) {
  .status-strip,
  .readout-grid,
  .audio-actions,
  .fps-controls,
  .typing-stats {
    grid-template-columns: 1fr;
  }

  .typing-results-grid {
    grid-template-columns: 1fr;
  }

  .keyboard-shell {
    padding: 10px;
  }

  .typing-prompt {
    min-height: 180px;
  }

  .mouse-pad-overlay {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: calc(100% - 28px);
    top: 62px;
  }

  .refresh-overlay {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: calc(100% - 76px);
  }
}
