
.kb,
.kb * {
  box-sizing: border-box;
}
.kb {
  display: grid;
  gap: 10px;
  min-width: 0;
  max-width: 100%;
  padding: 10px;
  border: 1px solid var(--line, #cad5ca);
  border-radius: var(--radius, 16px);
  background: var(--paper, #fbfaf5);
  color: var(--ink, #18312b);
  -webkit-tap-highlight-color: transparent;
}
.kb [hidden] {
  display: none !important;
}
.kb:focus {
  outline: none;
}
.kb:focus-visible {
  outline: 3px solid #a94b07;
  outline-offset: 3px;
}
.kb ::selection {
  background: var(--warm, #f3e9c6);
  color: var(--deep, #103f32);
}

.kb-display {
  min-height: 3.6rem;
  margin: 0;
  padding: 10px 14px;
  border: 2px solid #788a79;
  border-radius: 12px;
  background: var(--white, #fff);
  font-size: 1.5rem;
  font-weight: 650;
  line-height: 1.3;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.kb-caret {
  display: inline-block;
  width: 3px;
  height: 1.15em;
  margin: 0 2px 0 1px;
  border-radius: 2px;
  background: var(--green, #185b46);
  vertical-align: -0.2em;
  animation: kb-caret 1.1s steps(1) infinite;
}
.kb-placeholder {
  color: var(--muted, #53675d);
  font-weight: 500;
}
@keyframes kb-caret {
  50% {
    opacity: 0;
  }
}

.kb :where(button) {
  margin: 0;
  font: inherit;
  font-weight: 700;
  line-height: 1.15;
  color: var(--deep, #103f32);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.kb button:focus-visible {
  outline: 3px solid #a94b07;
  outline-offset: 2px;
}
.kb button:active:enabled {
  transform: translateY(1px);
}
.kb button:disabled {
  cursor: default;
  opacity: 0.48;
}

.kb-suggestions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(7rem, 100%), 1fr));
  gap: 8px;
  min-width: 0;
}
.kb-suggestion {
  min-width: 0;
  min-height: 60px;
  padding: 6px 12px;
  border: 2px solid #8a7536;
  border-radius: 14px;
  background: var(--warm, #f3e9c6);
  font-size: 1.3rem;
  font-weight: 750;
  overflow-wrap: anywhere;
  hyphens: auto;
  box-shadow: 0 2px 0 #e2d6a8;
}
.kb-suggestion[data-empty='true'] {
  visibility: hidden;
}

.kb-letters {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
  gap: 5px;
  min-width: 0;
}
.kb-key {
  min-width: 44px;
  min-height: 50px;
  padding: 2px;
  border: 1px solid #b4c2b5;
  border-radius: 10px;
  background: var(--white, #fff);
  color: var(--ink, #18312b);
  font-size: 1.35rem;
  box-shadow: 0 2px 0 #dbe2d9;
}
.kb-punct {
  background: var(--pale, #e2eee5);
  color: var(--deep, #103f32);
}
.kb-key:active:enabled {
  background: var(--pale, #e2eee5);
}

.kb-fns {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}
.kb-fn {
  flex: 1 1 0;
  min-width: auto;
  min-height: 52px;
  padding: 6px 8px;
  border: 1px solid #b4c2b5;
  border-radius: 11px;
  background: var(--white, #fff);
  font-size: 1rem;
  box-shadow: 0 2px 0 #dbe2d9;
}
.kb-space {
  flex-grow: 3;
}
.kb-shift[aria-pressed='true'] {
  border-color: var(--deep, #103f32);
  background: var(--deep, #103f32);
  color: var(--white, #fff);
  box-shadow: none;
}
.kb-speak {
  border-color: #b0cbb4;
  background: var(--pale, #e2eee5);
}
.kb-commit {
  flex-grow: 2;
  border: 2px solid var(--green, #185b46);
  background: var(--green, #185b46);
  color: var(--white, #fff);
}
.kb-close {
  border: 2px solid var(--green, #185b46);
  color: var(--green, #185b46);
}

@media (hover: hover) {
  .kb-key:hover:enabled,
  .kb-fn:hover:enabled {
    box-shadow: 0 2px 0 #b1c5b1;
  }
  .kb-suggestion:hover:enabled {
    box-shadow: 0 2px 0 #c9b77a;
  }
  .kb-commit:hover:enabled {
    background: var(--deep, #103f32);
  }
}

@media (prefers-reduced-motion: reduce) {
  .kb-caret {
    animation: none;
  }
  .kb button:active:enabled {
    transform: none;
  }
}

@media (forced-colors: active) {
  .kb-caret {
    background: CanvasText;
  }
  .kb-suggestion {
    border-width: 3px;
  }
  .kb-shift[aria-pressed='true'] {
    outline: 3px solid Highlight;
    outline-offset: -5px;
  }
}
