:root {
  --page-bg: #050706;
  --text: #f4f6f2;
  --muted: rgba(244, 246, 242, 0.58);
  --line: rgba(255, 255, 255, 0.14);
  --command: rgba(190, 232, 205, 0.72);
  --command-strong: rgba(136, 218, 168, 0.9);
  --shadow: rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 22% 18%, rgba(228, 230, 200, 0.18), transparent 28%),
    radial-gradient(circle at 78% 25%, rgba(68, 213, 148, 0.18), transparent 32%),
    var(--page-bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  letter-spacing: 0;
  overflow-x: hidden;
}

button {
  font: inherit;
}

.app {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.workbench {
  width: min(100%, 1316px);
}

.stage {
  position: relative;
  width: 100%;
  aspect-ratio: 1316 / 532;
  margin-top: 16px;
  isolation: isolate;
  border-radius: 12px;
  overflow: hidden;
  background: #070807;
  box-shadow:
    0 22px 80px rgba(0, 0, 0, 0.46),
    0 1px 0 rgba(255, 255, 255, 0.08);
}

.keyboard-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
  pointer-events: none;
  z-index: 1;
}

.key-layer {
  position: absolute;
  inset: 0;
  z-index: 3;
}

.key {
  appearance: none;
  position: absolute;
  left: calc(var(--x) * 1%);
  top: calc(var(--y) * 1%);
  width: calc(var(--w) * 1%);
  height: calc(var(--h) * 1%);
  padding: 0;
  border: 0;
  border-radius: min(0.95vw, 10px);
  transform: translateY(0) scale(1);
  transform-origin: 50% 55%;
  transition:
    transform 130ms ease,
    background 170ms ease,
    box-shadow 170ms ease,
    filter 170ms ease,
    opacity 170ms ease;
  opacity: 0;
  pointer-events: auto;
  cursor: pointer;
}

.key::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border: 1px solid transparent;
  transition: border-color 170ms ease;
}

.key.is-pressed {
  opacity: 0.96;
  transform: translateY(2.4%) scale(0.986);
  background:
    linear-gradient(180deg, rgba(235, 252, 241, 0.92), rgba(176, 235, 198, 0.88) 56%, rgba(124, 213, 158, 0.86)),
    radial-gradient(circle at 50% 8%, rgba(255, 255, 255, 0.82), transparent 48%);
  box-shadow:
    inset 0 5px 10px rgba(255, 255, 255, 0.58),
    inset 0 -12px 20px rgba(67, 158, 101, 0.42),
    0 0 0 2px rgba(102, 208, 143, 0.68),
    0 9px 26px rgba(84, 212, 134, 0.32);
  filter: saturate(1.16);
}

.key.is-pressed::after {
  border-color: rgba(100, 191, 134, 0.52);
}

.mini-screen {
  width: 100%;
  height: 280px;
  display: block;
  padding: 34px 42px;
  border: 1px solid rgba(255, 255, 255, 0.38);
  border-radius: 10px;
  background:
    linear-gradient(180deg, rgba(15, 29, 23, 0.72), rgba(10, 18, 16, 0.66)),
    rgba(9, 19, 15, 0.72);
  box-shadow:
    inset 0 1px 1px rgba(255, 255, 255, 0.2),
    inset 0 -10px 18px rgba(0, 0, 0, 0.18),
    0 10px 28px rgba(0, 0, 0, 0.16);
  color: #dff5e7;
  overflow: hidden;
  backdrop-filter: blur(14px);
}

.screen-text {
  width: 100%;
  height: 100%;
  overflow-y: auto;
  scrollbar-width: none;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  text-overflow: clip;
  font-family: "SF Mono", "Roboto Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: 34px;
  line-height: 1.34;
  text-shadow: 0 0 16px rgba(128, 231, 167, 0.58);
}

.screen-text::-webkit-scrollbar {
  display: none;
}

.screen-text.is-empty .screen-content {
  color: rgba(223, 245, 231, 0.43);
}

.caret {
  display: inline-block;
  width: 8px;
  height: 0.95em;
  margin-left: 4px;
  transform: translateY(0.14em);
  border-radius: 2px;
  background: #bff2cf;
  box-shadow: 0 0 14px rgba(136, 238, 172, 0.78);
  animation: blink 1s steps(2, start) infinite;
  flex: 0 0 auto;
}

.panel {
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 4px 0;
}

.history {
  margin-top: 10px;
  padding: 12px 4px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.history h2 {
  margin: 0;
  color: rgba(244, 246, 242, 0.72);
  font-size: 14px;
  font-weight: 650;
  line-height: 1.4;
}

.history-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(152px, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.history-item {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
  color: rgba(244, 246, 242, 0.76);
  font-size: 13px;
  line-height: 1.2;
}

.history-item.is-live {
  border-color: rgba(136, 218, 168, 0.34);
  background: rgba(136, 218, 168, 0.08);
}

.history-time {
  color: var(--text);
  font-weight: 650;
}

.history-count {
  text-align: right;
  color: var(--muted);
}

.empty-history {
  margin: 0;
  color: rgba(244, 246, 242, 0.38);
  font-size: 13px;
}

.metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
}

.metrics strong {
  color: var(--text);
  font-weight: 650;
}

.reset-button {
  height: 34px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  cursor: pointer;
  transition:
    background 150ms ease,
    border-color 150ms ease,
    transform 150ms ease;
}

.ghost-button {
  height: 28px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: rgba(244, 246, 242, 0.52);
  cursor: pointer;
  font-size: 12px;
  transition:
    color 150ms ease,
    background 150ms ease,
    border-color 150ms ease;
}

.reset-button:hover,
.ghost-button:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.26);
  color: var(--text);
}

.reset-button:active {
  transform: translateY(1px);
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

@media (max-width: 760px) {
  .app {
    min-height: 100svh;
    padding: 14px;
  }

  .stage {
    border-radius: 8px;
    margin-top: 10px;
  }

  .mini-screen {
    height: 170px;
    padding: 20px 18px;
    border-radius: 7px;
  }

  .screen-text {
    font-size: 24px;
  }

  .caret {
    width: 6px;
  }

  .panel {
    align-items: flex-start;
  }

  .history-list {
    grid-template-columns: 1fr;
  }

  .metrics {
    font-size: 12px;
    gap: 6px 10px;
  }

  .reset-button {
    height: 32px;
    padding: 0 12px;
    border-radius: 7px;
    font-size: 13px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
