:root {
  --bg: #f5f5f7;
  --text: #1d1d1f;
  --secondary: #6e6e73;
  --tertiary: #6e6e73;   /* small text: keeps 4.5:1 contrast on the light background */
  --fill: rgba(118, 118, 128, 0.12);
  --fill-strong: rgba(118, 118, 128, 0.2);
  --surface: #ffffff;
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --shadow: 0 3px 8px rgba(0, 0, 0, 0.12), 0 3px 1px rgba(0, 0, 0, 0.04);

  /* keyboard: always Space Black, like the MacBook */
  --deck: #1c1c1e;
  --deck-edge: #2c2c2e;
  --key: #0b0b0c;
  --key-top: #18181a;
  --key-down: #2a2a2d;
  --legend: #f5f5f7;
  --gap: calc(var(--u) * 0.12);
  --u: min(54px, calc((100vw - 48px) / 15.6));
  --display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro", system-ui, "Helvetica Neue", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --text: #f5f5f7;
    --secondary: #a1a1a6;
    --tertiary: #86868b;
    --fill: rgba(118, 118, 128, 0.24);
    --fill-strong: rgba(118, 118, 128, 0.36);
    --surface: #636366;
    --accent: #2997ff;
    --accent-hover: #47a6ff;
    --deck: #161617;
    --deck-edge: #2c2c2e;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  /* SF Pro: -apple-system resolves to it on every Mac, iPhone and iPad. Apple's license doesn't
     allow hosting SF Pro as a web font, so other platforms fall back to their system UI font. */
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro", system-ui, "Helvetica Neue", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.47;
  overflow-x: hidden;
  /* This is a typing toy: double-clicks, rapid key taps and ⌘A shouldn't highlight the page.
     (Keys and the deck were already unselectable; this covers everything around them.) */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* ---------- top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--fill-strong);
}

.topbar-inner {
  max-width: 980px;
  height: 48px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar-right { display: flex; align-items: center; gap: 20px; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-family: var(--display);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.brand img { border-radius: 5px; }

.pill {
  padding: 4px 12px;
  border-radius: 980px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  text-decoration: none;
  transition: background 0.2s;
}

.pill:hover { background: var(--accent-hover); }

.topbar-right a:not(.pill) { color: var(--text); font-size: 13px; text-decoration: none; opacity: 0.8; }
.topbar-right a:not(.pill):hover { opacity: 1; }

main {
  max-width: 980px;
  margin: 0 auto;
  padding: 56px 16px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

/* ---------- hero ---------- */

.logo {
  width: 96px;
  height: 96px;
  filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.18));
}

h1 {
  margin: 20px 0 4px;
  font-family: var(--display);
  font-size: clamp(40px, 7vw, 64px);
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.05;
}

.tagline {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(19px, 2.4vw, 24px);
  color: var(--secondary);
  letter-spacing: -0.01em;
}

/* ---------- typing stage ---------- */

.stage {
  margin-top: 56px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.typed {
  margin: 0;
  min-height: 1.3em;
  max-width: 100%;
  font-family: var(--display);
  font-size: clamp(22px, 3.4vw, 32px);
  font-weight: 300;
  letter-spacing: -0.01em;
  white-space: pre;
  overflow: hidden;
}

.caret {
  display: inline-block;
  width: 2px;
  height: 1.05em;
  margin-left: 2px;
  vertical-align: -0.15em;
  background: var(--accent);
  animation: blink 1.1s steps(1) infinite;
}

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

.hint {
  margin: 6px 0 28px;
  font-size: 15px;
  color: var(--tertiary);
  transition: opacity 0.4s;
}

.hint.hidden { opacity: 0; }

/* ---------- keyboard ---------- */

.deck {
  padding: calc(var(--u) * 0.32);
  border-radius: calc(var(--u) * 0.42);
  background: linear-gradient(180deg, var(--deck-edge), var(--deck) 12%);
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.row { display: flex; gap: var(--gap); }

.key {
  --w: 1;
  position: relative;
  width: calc(var(--u) * var(--w) + var(--gap) * (var(--w) - 1));
  height: var(--u);
  border: 0;
  padding: 0;
  border-radius: calc(var(--u) * 0.12);
  background: linear-gradient(180deg, var(--key-top), var(--key));
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.07) inset, 0 1px 2px rgba(0, 0, 0, 0.6);
  color: var(--legend);
  font: inherit;
  font-size: calc(var(--u) * 0.27);
  cursor: pointer;
  transition: transform 0.06s, background 0.12s, box-shadow 0.12s;
  -webkit-tap-highlight-color: transparent;
}

.key .main {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

.key.mod .main { display: none; }

.key .word,
.key .sym {
  position: absolute;
  font-size: calc(var(--u) * 0.19);
  line-height: 1;
  opacity: 0.92;
}

.key .word { left: calc(var(--u) * 0.12); bottom: calc(var(--u) * 0.12); }
.key .sym { right: calc(var(--u) * 0.12); top: calc(var(--u) * 0.12); font-size: calc(var(--u) * 0.24); }
.key.right .word { left: auto; right: calc(var(--u) * 0.12); }
.key.right .sym { right: auto; left: calc(var(--u) * 0.12); }

.key .globe {
  position: absolute;
  left: calc(var(--u) * 0.13);
  bottom: calc(var(--u) * 0.13);
  width: calc(var(--u) * 0.26);
  height: calc(var(--u) * 0.26);
}

.key.down {
  transform: translateY(1px);
  background: linear-gradient(180deg, #303034, var(--key-down));
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.1) inset, 0 0 14px rgba(255, 255, 255, 0.08);
}

.arrows { display: flex; gap: var(--gap); align-items: flex-end; }
.arrows .stack { display: flex; flex-direction: column; gap: calc(var(--gap) * 0.5); }
.arrows .key { height: calc(var(--u) * 0.48); font-size: calc(var(--u) * 0.2); }

/* ---------- controls ---------- */

.controls {
  margin-top: 40px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 20px 32px;
}

.segmented {
  display: inline-flex;
  padding: 2px;
  border-radius: 9px;
  background: var(--fill);
}

.segmented button {
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  padding: 6px 16px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s;
}

.segmented button[aria-checked="true"] {
  background: var(--surface);
  box-shadow: var(--shadow);
  font-weight: 500;
}

.slider { display: inline-flex; align-items: center; gap: 10px; font-size: 14px; color: var(--secondary); }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 140px;
  height: 4px;
  border-radius: 2px;
  background: var(--fill-strong);
  accent-color: var(--accent);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0.5px 4px rgba(0, 0, 0, 0.12), 0 6px 13px rgba(0, 0, 0, 0.12);
  border: 0.5px solid rgba(0, 0, 0, 0.04);
}

input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  border: 0;
  box-shadow: 0 0.5px 4px rgba(0, 0, 0, 0.12), 0 6px 13px rgba(0, 0, 0, 0.12);
}

.switches { display: inline-flex; gap: 20px; }

.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--secondary);
  cursor: pointer;
}

.switch input { position: absolute; opacity: 0; pointer-events: none; }

.switch span {
  position: relative;
  width: 38px;
  height: 23px;
  border-radius: 12px;
  background: var(--fill-strong);
  transition: background 0.2s;
}

.switch span::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s;
}

.switch input:checked + span { background: #34c759; }
.switch input:checked + span::after { transform: translateX(15px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- call to action ---------- */

.cta {
  margin-top: 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.button {
  display: inline-block;
  padding: 12px 24px;
  border-radius: 980px;
  background: var(--accent);
  color: #fff;
  font-size: 17px;
  text-decoration: none;
  transition: background 0.2s;
}

.button:hover { background: var(--accent-hover); }

.cta-note { margin: 0; font-size: 12px; color: var(--tertiary); }
.cta-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 28px; margin-top: 2px; }

.link { color: var(--accent); font-size: 17px; text-decoration: none; }
.link:hover { text-decoration: underline; }

/* ---------- share ---------- */

.share {
  margin-top: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.share img {
  width: 96px;
  height: 96px;
  border-radius: 14px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.06), 0 4px 14px rgba(0, 0, 0, 0.08);
  image-rendering: pixelated;   /* keep the modules crisp */
}

.share p { margin: 0; font-size: 12px; color: var(--tertiary); }

footer {
  padding: 24px 16px 40px;
  text-align: center;
  font-size: 12px;
  color: var(--tertiary);
}

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

footer a { color: var(--tertiary); text-decoration: none; }
footer .copyright { margin: 8px 0 0; }
footer .kofi { color: var(--accent); }
footer .kofi:hover { text-decoration: underline; }
footer a:hover { text-decoration: underline; }

@media (max-width: 600px) {
  main { padding-top: 40px; }
  .stage { margin-top: 36px; }
  .switches { gap: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
