:root {
  --keyboard-max: 1240px;
  --keyboard-shell: rgba(255, 255, 255, 0.46);
  --keyboard-panel: rgba(255, 255, 255, 0.52);
  --keyboard-key: #edf5f1;
  --keyboard-key-ink: #185044;
  --keyboard-key-border: rgba(14, 114, 95, 0.17);
  --keyboard-active: #df756c;
  --keyboard-tested: #119b7d;
}

* {
  box-sizing: border-box;
}

.keyboard-page {
  padding-bottom: 36px;
}

.keyboard-hero,
.keyboard-workspace,
.tester-benefits,
.tester-notes {
  width: min(calc(100% - 40px), var(--keyboard-max));
  margin-right: auto;
  margin-left: auto;
}

.keyboard-hero {
  grid-template-columns: minmax(0, 1fr) 220px;
  min-height: 390px;
  padding-bottom: 58px;
}

.keyboard-hero h1 {
  max-width: 12ch;
  font-size: clamp(3.7rem, 8vw, 7.3rem);
  line-height: 0.9;
}

.keyboard-hero .lede {
  max-width: 650px;
}

.keyboard-workspace {
  padding: clamp(20px, 3vw, 36px);
  border: 1px solid rgba(14, 114, 95, 0.2);
  border-radius: 12px;
  background: var(--keyboard-shell);
  box-shadow: 0 24px 70px rgba(29, 42, 38, 0.12);
  backdrop-filter: blur(18px);
}

.workspace-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 28px;
}

.workspace-heading .kicker {
  margin-bottom: 8px;
}

.workspace-heading h2 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(2rem, 4vw, 3.6rem);
  line-height: 1;
}

.live-status {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 36px;
  padding: 8px 13px;
  border: 1px solid rgba(14, 114, 95, 0.18);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.36);
  color: var(--mint-dark);
  font-size: 0.84rem;
  font-weight: 800;
  white-space: nowrap;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--keyboard-tested);
  box-shadow: 0 0 0 5px rgba(17, 155, 125, 0.12);
}

.tester-toolbar {
  display: grid;
  grid-template-columns: minmax(190px, 0.8fr) minmax(280px, 1fr) auto;
  gap: 14px;
  align-items: stretch;
  margin-bottom: 18px;
}

.layout-control,
.readout-item {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
}

.layout-control {
  min-height: 66px;
  padding: 9px 14px;
  border: 1px solid rgba(14, 114, 95, 0.18);
  border-radius: 8px;
  background: var(--keyboard-panel);
}

.layout-control > span,
.readout-item small {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 850;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.layout-control select {
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.98rem;
  font-weight: 800;
  cursor: pointer;
}

.layout-control select:focus-visible {
  outline: 2px solid rgba(14, 114, 95, 0.38);
  outline-offset: 4px;
}

.test-readout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  overflow: hidden;
  border: 1px solid rgba(14, 114, 95, 0.18);
  border-radius: 8px;
  background: var(--keyboard-panel);
}

.readout-item {
  min-width: 0;
  padding: 10px 16px;
}

.readout-item + .readout-item {
  border-left: 1px solid rgba(14, 114, 95, 0.14);
}

.readout-item strong {
  overflow: hidden;
  color: var(--ink);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.94rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reset-button {
  min-width: 132px;
  padding: 0 18px;
  border: 1px solid rgba(14, 114, 95, 0.3);
  border-radius: 8px;
  background: transparent;
  color: var(--mint-dark);
  font: inherit;
  font-weight: 850;
  cursor: pointer;
  transition: background 180ms ease, border-color 180ms ease, transform 180ms ease;
}

.reset-button:hover {
  border-color: var(--mint-dark);
  background: rgba(255, 255, 255, 0.36);
  transform: translateY(-1px);
}

.reset-button:focus-visible {
  outline: 3px solid rgba(82, 189, 168, 0.34);
  outline-offset: 3px;
}

.keyboard-frame {
  overflow: hidden;
  border: 1px solid rgba(14, 114, 95, 0.18);
  border-radius: 10px;
  background: rgba(242, 250, 247, 0.62);
}

.scroll-hint {
  display: none;
  margin: 0;
  padding: 10px 16px 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.keyboard-viewport {
  overflow-x: auto;
  padding: clamp(14px, 2vw, 24px);
  overscroll-behavior-inline: contain;
  scrollbar-color: rgba(14, 114, 95, 0.34) transparent;
  scrollbar-width: thin;
}

.keyboard-stage {
  min-width: 920px;
  padding: 14px;
  border: 1px solid rgba(14, 114, 95, 0.16);
  border-radius: 10px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(228, 240, 235, 0.7));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 15px 35px rgba(29, 42, 38, 0.09);
}

.keyboard-stage:focus-visible {
  outline: 3px solid rgba(82, 189, 168, 0.36);
  outline-offset: 3px;
}

#kbd {
  position: relative;
  width: 100%;
  height: auto;
  aspect-ratio: 23.5 / 6.5;
  margin: 0;
  border: 0;
  container-type: inline-size;
}

#kbd .key {
  position: absolute;
  display: inline-block;
  overflow: visible;
  border: 1px solid var(--keyboard-key-border);
  border-radius: 6px;
  color: var(--keyboard-key-ink);
  box-shadow:
    inset 0 -3px 0 rgba(20, 68, 57, 0.11),
    0 2px 4px rgba(29, 42, 38, 0.08);
  user-select: none;
  transition:
    background-color 110ms ease,
    border-color 110ms ease,
    box-shadow 110ms ease,
    color 110ms ease,
    transform 110ms ease;
}

#kbd .in {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 2px;
  line-height: 1;
  text-align: center;
}

#kbd .inin_std,
#kbd .inin_mod,
#kbd .inin_modsmall {
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-weight: 760;
  line-height: 1.05;
}

#kbd .inin_std {
  font-size: 14px;
  font-size: clamp(0.72rem, 1.42cqw, 1rem);
}

#kbd .inin_mod {
  font-size: 9px;
  font-size: clamp(0.58rem, 0.8cqw, 0.72rem);
}

#kbd .inin_modsmall {
  font-size: 8px;
  font-size: clamp(0.52rem, 0.68cqw, 0.64rem);
}

#kbd .st_off {
  background: var(--keyboard-key);
}

#kbd .st_on {
  z-index: 2;
  border-color: rgba(143, 66, 59, 0.5);
  background: var(--keyboard-active);
  color: #fff;
  box-shadow:
    inset 0 -2px 0 rgba(107, 43, 38, 0.26),
    0 0 0 3px rgba(223, 117, 108, 0.18),
    0 6px 13px rgba(120, 50, 45, 0.18);
  transform: translateY(2px);
}

#kbd .st_mark {
  border-color: rgba(8, 110, 87, 0.5);
  background: var(--keyboard-tested);
  color: #fff;
  box-shadow:
    inset 0 -3px 0 rgba(5, 84, 66, 0.2),
    0 3px 8px rgba(4, 101, 78, 0.14);
}

#kbd .key .tooltip {
  position: absolute;
  top: calc(100% + 7px);
  left: 50%;
  z-index: 20;
  visibility: hidden;
  width: max-content;
  max-width: 180px;
  padding: 5px 8px;
  border-radius: 5px;
  background: #183e35;
  color: #eafff8;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 10px;
  line-height: 1.2;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -3px);
  transition: opacity 120ms ease, transform 120ms ease, visibility 120ms ease;
}

#kbd .key:hover {
  z-index: 10;
}

#kbd .key:hover .tooltip {
  visibility: visible;
  opacity: 1;
  transform: translate(-50%, 0);
}

.keyboard-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px clamp(16px, 2vw, 24px);
  border-top: 1px solid rgba(14, 114, 95, 0.13);
}

.key-legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
}

.key-legend > span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 0.77rem;
  font-weight: 750;
}

.legend-key {
  width: 17px;
  height: 14px;
  border: 1px solid var(--keyboard-key-border);
  border-radius: 3px;
  background: var(--keyboard-key);
  box-shadow: inset 0 -2px 0 rgba(20, 68, 57, 0.11);
}

.legend-key.active {
  border-color: var(--keyboard-active);
  background: var(--keyboard-active);
}

.legend-key.tested {
  border-color: var(--keyboard-tested);
  background: var(--keyboard-tested);
}

.focus-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.77rem;
  text-align: right;
}

.error-message {
  min-height: 0;
  margin: 0;
  padding: 0 clamp(16px, 2vw, 24px);
  color: #9c443c;
  font-size: 0.82rem;
  font-weight: 750;
}

.error-message:not(:empty) {
  padding-top: 12px;
  padding-bottom: 12px;
  border-top: 1px solid rgba(161, 92, 84, 0.18);
  background: rgba(223, 117, 108, 0.08);
}

.error-message .tt {
  color: inherit;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
}

.tester-benefits {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  margin-top: 74px;
  overflow: hidden;
  border-top: 1px solid rgba(14, 114, 95, 0.22);
  border-bottom: 1px solid rgba(14, 114, 95, 0.22);
  background: rgba(14, 114, 95, 0.18);
}

.tester-benefits article {
  min-height: 220px;
  padding: clamp(24px, 4vw, 42px);
  background: rgba(255, 255, 255, 0.42);
}

.benefit-number {
  display: block;
  margin-bottom: 36px;
  color: var(--mint-dark);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.76rem;
  font-weight: 850;
}

.tester-benefits h2 {
  margin-bottom: 10px;
  color: var(--ink);
  font-size: clamp(1.3rem, 2.4vw, 1.8rem);
}

.tester-benefits p,
.notes-intro > p:last-child,
.notes-list details p {
  margin: 0;
  color: var(--muted);
}

.tester-notes {
  display: grid;
  grid-template-columns: minmax(260px, 0.75fr) minmax(0, 1.25fr);
  gap: clamp(40px, 8vw, 110px);
  padding: 88px 0 68px;
}

.notes-intro h2 {
  margin-bottom: 18px;
  color: var(--ink);
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 1;
}

.notes-list {
  border-top: 1px solid rgba(14, 114, 95, 0.24);
}

.notes-list details {
  border-bottom: 1px solid rgba(14, 114, 95, 0.24);
}

.notes-list summary {
  position: relative;
  padding: 20px 42px 20px 0;
  color: var(--ink);
  font-weight: 820;
  cursor: pointer;
  list-style: none;
}

.notes-list summary::-webkit-details-marker {
  display: none;
}

.notes-list summary::after {
  content: "+";
  position: absolute;
  top: 50%;
  right: 3px;
  color: var(--mint-dark);
  font-size: 1.4rem;
  font-weight: 400;
  transform: translateY(-50%);
}

.notes-list details[open] summary::after {
  content: "−";
}

.notes-list details p {
  max-width: 68ch;
  padding: 0 42px 22px 0;
  line-height: 1.7;
}

.tester-notes code {
  padding: 0.1em 0.35em;
  border-radius: 4px;
  background: rgba(14, 114, 95, 0.1);
  color: var(--mint-dark);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.9em;
}

html[data-theme="dark"] {
  --keyboard-shell: rgba(42, 48, 46, 0.76);
  --keyboard-panel: rgba(20, 26, 24, 0.62);
  --keyboard-key: #35413d;
  --keyboard-key-ink: #d9fff5;
  --keyboard-key-border: rgba(98, 214, 190, 0.2);
  --keyboard-active: #bf6962;
  --keyboard-tested: #148f75;
}

html[data-theme="dark"] .keyboard-workspace,
html[data-theme="dark"] .keyboard-frame,
html[data-theme="dark"] .keyboard-stage,
html[data-theme="dark"] .live-status {
  border-color: rgba(82, 189, 168, 0.2);
}

html[data-theme="dark"] .keyboard-frame {
  background: rgba(24, 31, 29, 0.68);
}

html[data-theme="dark"] .keyboard-stage {
  background: linear-gradient(180deg, rgba(48, 58, 55, 0.86), rgba(31, 39, 36, 0.9));
  box-shadow:
    inset 0 1px 0 rgba(143, 228, 208, 0.06),
    0 18px 42px rgba(0, 0, 0, 0.24);
}

html[data-theme="dark"] .live-status {
  background: rgba(20, 26, 24, 0.54);
  color: var(--mint);
}

html[data-theme="dark"] .layout-control,
html[data-theme="dark"] .test-readout {
  border-color: rgba(82, 189, 168, 0.2);
}

html[data-theme="dark"] .readout-item + .readout-item,
html[data-theme="dark"] .keyboard-footer {
  border-color: rgba(82, 189, 168, 0.16);
}

html[data-theme="dark"] .tester-benefits {
  border-color: rgba(82, 189, 168, 0.22);
  background: rgba(82, 189, 168, 0.16);
}

html[data-theme="dark"] .tester-benefits article {
  background: rgba(42, 48, 46, 0.78);
}

html[data-theme="dark"] .notes-list,
html[data-theme="dark"] .notes-list details {
  border-color: rgba(82, 189, 168, 0.22);
}

html[data-theme="dark"] .error-message {
  color: #f0aaa3;
}

@media (max-width: 980px) {
  .keyboard-hero {
    min-height: 0;
  }

  .tester-toolbar {
    grid-template-columns: minmax(180px, 0.8fr) minmax(280px, 1.2fr);
  }

  .reset-button {
    grid-column: 1 / -1;
    min-height: 50px;
  }

  .tester-benefits {
    grid-template-columns: 1fr;
  }

  .tester-benefits article {
    min-height: 0;
  }

  .benefit-number {
    margin-bottom: 20px;
  }
}

@media (max-width: 760px) {
  .keyboard-hero,
  .keyboard-workspace,
  .tester-benefits,
  .tester-notes {
    width: min(calc(100% - 28px), var(--keyboard-max));
  }

  .keyboard-hero {
    grid-template-columns: 1fr;
    padding-top: 38px;
  }

  .keyboard-hero .page-logo {
    display: none;
  }

  .keyboard-hero h1 {
    font-size: clamp(3.2rem, 17vw, 5.3rem);
  }

  .workspace-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 18px;
  }

  .tester-toolbar {
    grid-template-columns: 1fr;
  }

  .reset-button {
    grid-column: auto;
  }

  .scroll-hint {
    display: block;
  }

  .keyboard-viewport {
    padding: 14px;
  }

  .keyboard-stage {
    min-width: 860px;
  }

  .keyboard-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .focus-note {
    text-align: left;
  }

  .tester-notes {
    grid-template-columns: 1fr;
    gap: 40px;
    padding-top: 68px;
  }
}

@media (max-width: 430px) {
  .keyboard-workspace {
    padding: 17px;
  }

  .test-readout {
    grid-template-columns: 1fr;
  }

  .readout-item + .readout-item {
    border-top: 1px solid rgba(14, 114, 95, 0.14);
    border-left: 0;
  }

  .key-legend {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  #kbd .key,
  .reset-button {
    transition-duration: 1ms;
  }
}
