:root {
  --ink: #0a0a0c;
  --elevated: #121116;
  --line: #232028;
  --bone: #e8e6ea;
  --soft: #a8a5ad;
  --muted: #6b6873;
  --pink: #ff5c8a;
  --pink-soft: rgba(255, 92, 138, 0.12);
  --pink-glow: rgba(255, 92, 138, 0.35);
  --violet: rgba(130, 70, 190, 0.16);
  --grid: rgba(255, 255, 255, 0.025);
  --font-body:
    "Geist",
    system-ui,
    -apple-system,
    sans-serif;
  --font-mono:
    "Geist Mono",
    ui-monospace,
    "SF Mono",
    Menlo,
    monospace;
  --font-pixel: "DotGothic16", var(--font-mono);
}
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html,
body {
  height: 100%;
}
body {
  background: var(--ink);
  color: var(--bone);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}
::selection {
  background: var(--pink);
  color: var(--ink);
}
html {
  scrollbar-width: thin;
  scrollbar-color: #2e2b36 transparent;
}
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #2e2b36;
  border-radius: 999px;
  border: 3px solid var(--ink);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--pink);
}
a {
  color: inherit;
  text-decoration: none;
}
a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--pink);
  outline-offset: 3px;
  border-radius: 2px;
}
button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}
.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(
      90deg,
      var(--grid) 1px,
      transparent 1px);
  background-size: 44px 44px;
}
.bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(
      ellipse 70% 60% at 50% 40%,
      transparent 30%,
      var(--ink) 100%);
}
.blob {
  position: absolute;
  width: 480px;
  height: 480px;
  border-radius: 50%;
  filter: blur(110px);
  opacity: 0.5;
}
.blob-1 {
  background: var(--violet);
  top: -160px;
  left: 12%;
  animation: drift-1 26s ease-in-out infinite alternate;
}
.blob-2 {
  background: var(--pink-soft);
  bottom: -200px;
  right: 4%;
  animation: drift-2 32s ease-in-out infinite alternate;
}
@keyframes drift-1 {
  from {
    transform: translate(0, 0) scale(1);
  }
  to {
    transform: translate(120px, 80px) scale(1.15);
  }
}
@keyframes drift-2 {
  from {
    transform: translate(0, 0) scale(1.1);
  }
  to {
    transform: translate(-140px, -70px) scale(0.95);
  }
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
}
.tb-logo {
  display: flex;
  align-items: baseline;
  gap: 2px;
}
.tb-logo .lg {
  font-family: var(--font-pixel);
  font-size: 19px;
  color: var(--pink);
  text-shadow: 0 0 18px var(--pink-glow);
  line-height: 1;
}
.tb-logo .tb-sub {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--muted);
}
.tb-right {
  font-family: var(--font-mono);
  font-size: 12px;
}
.tb-right a {
  color: var(--muted);
  transition: color 0.18s ease;
}
.tb-right a:hover {
  color: var(--pink);
}
.wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 16px 34px;
}
.machine {
  position: relative;
  width: min(400px, 100%);
  border: 1px solid var(--line);
  border-radius: 16px;
  background:
    linear-gradient(
      180deg,
      rgba(20, 17, 24, 0.88),
      rgba(12, 11, 15, 0.88));
  backdrop-filter: blur(14px);
  padding: 18px 18px 14px;
  display: flex;
  flex-direction: column;
  animation: rise 0.4s ease both;
}
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}
.machine::before {
  content: "";
  position: absolute;
  top: 0;
  left: 18%;
  right: 18%;
  height: 1px;
  background:
    linear-gradient(
      90deg,
      transparent,
      var(--pink-glow),
      transparent);
}
.tape-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2px 4px;
}
.kana {
  font-family: var(--font-pixel);
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.42em;
}
.tape-clear {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  transition: color 0.18s ease;
}
.tape-clear:hover {
  color: var(--pink);
}
.tape {
  max-height: 168px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  mask-image:
    linear-gradient(
      180deg,
      transparent 0,
      #000 18px);
  -webkit-mask-image:
    linear-gradient(
      180deg,
      transparent 0,
      #000 18px);
}
.tape:empty {
  display: none;
}
.trow {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  width: 100%;
  text-align: left;
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 5px 8px;
  border-radius: 6px;
  transition: background 0.18s ease;
  animation: rise 0.25s ease both;
}
.trow:hover {
  background: var(--elevated);
}
.trow .te {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color 0.18s ease;
}
.trow:hover .te {
  color: var(--soft);
}
.trow .tr {
  color: var(--soft);
  white-space: nowrap;
  flex-shrink: 0;
  transition: color 0.18s ease;
}
.trow:hover .tr {
  color: var(--pink);
}
.display {
  padding: 10px 8px 14px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
}
.display.shake {
  animation: shake 0.3s ease;
}
@keyframes shake {
  20% {
    transform: translateX(-5px);
  }
  45% {
    transform: translateX(4px);
  }
  70% {
    transform: translateX(-3px);
  }
  90% {
    transform: translateX(2px);
  }
}
.expr {
  width: 100%;
  background: none;
  border: none;
  outline: none;
  text-align: right;
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 400;
  color: var(--bone);
  caret-color: var(--pink);
  padding: 2px 0;
}
.expr::placeholder {
  color: var(--muted);
  opacity: 0.55;
}
.result-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
}
.err {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.err.on {
  color: var(--pink);
}
.result {
  margin-left: auto;
  font-family: var(--font-pixel);
  font-size: 40px;
  line-height: 1.2;
  color: var(--pink);
  text-shadow: 0 0 24px var(--pink-glow);
  opacity: 0.6;
  text-align: right;
  word-break: break-all;
  transition: opacity 0.18s ease;
  position: relative;
}
.result:empty {
  display: none;
}
.result.final {
  opacity: 1;
}
.result.pop {
  animation: pop 0.35s ease;
}
@keyframes pop {
  30% {
    text-shadow: 0 0 34px var(--pink-glow), 0 0 80px var(--pink-soft);
    transform: scale(1.03);
  }
}
.result:hover {
  opacity: 1;
}
.result::after {
  content: "copied";
  position: absolute;
  right: 0;
  top: -16px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--pink);
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}
.result.copied::after {
  opacity: 1;
}
.keys {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.key {
  height: 54px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(18, 17, 22, 0.5);
  font-family: var(--font-mono);
  font-size: 17px;
  color: var(--bone);
  transition:
    border-color 0.15s ease,
    background 0.15s ease,
    transform 0.08s ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.key:hover {
  border-color: var(--pink);
}
.key:active,
.key.pressed {
  transform: scale(0.94);
  background: var(--pink-soft);
  border-color: var(--pink);
}
.k-fn {
  color: var(--soft);
  font-size: 15px;
}
.k-op {
  color: var(--pink);
}
.k-eq {
  background: var(--pink);
  border-color: var(--pink);
  color: var(--ink);
  font-weight: 500;
}
.k-eq:hover {
  box-shadow: 0 0 24px var(--pink-glow);
}
.k-eq:active,
.k-eq.pressed {
  background: var(--pink);
  box-shadow: 0 0 24px var(--pink-glow);
}
.hint {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  padding-top: 12px;
  line-height: 1.6;
}
.hint b {
  font-weight: 400;
  color: var(--soft);
}
.hint span {
  white-space: nowrap;
}
@media (max-width: 440px) {
  .wrap {
    padding: 4px 10px 20px;
    align-items: flex-start;
  }
  .machine {
    padding: 14px 12px 10px;
  }
  .tape {
    max-height: 108px;
  }
  .result {
    font-size: 34px;
  }
  .expr {
    font-size: 19px;
  }
  .key {
    height: max(48px, 12.5vw);
  }
}
@media (max-height: 700px) {
  .tape {
    max-height: 96px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .blob-1,
  .blob-2 {
    animation: none;
  }
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
