:root {
  color-scheme: dark;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
  background: #111111;
  color: #f5f5f7;
}

* { box-sizing: border-box; }

body { margin: 0; min-width: 320px; background: #111111; }
button { font: inherit; cursor: pointer; }

.app-shell { min-height: 100svh; padding: clamp(18px, 3vw, 48px); display: grid; place-items: center; }
.hidden { display: none !important; }

.welcome { width: min(640px, 100%); text-align: center; }
.wordmark { margin: 0 0 32px; color: #ffffff; font-size: 1.1rem; font-weight: 680; letter-spacing: -.02em; }
.welcome h1 { margin: 0; color: #fff; font-size: clamp(2.5rem, 7vw, 5rem); font-weight: 680; letter-spacing: -.06em; line-height: .98; }
.welcome > p:not(.wordmark) { max-width: 540px; margin: 24px auto 0; color: #a1a1a6; font-size: 1.06rem; line-height: 1.55; }
.welcome-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 12px; margin-top: 34px; }
.start-button, .quiet-button { min-height: 52px; padding: 0 22px; border-radius: 14px; font-weight: 660; }
.start-button { border: 1px solid #fff; background: #fff; color: #111; }
.quiet-button { border: 1px solid #424247; background: #1c1c1e; color: #fff; }

.communicator { width: min(1180px, 100%); height: min(900px, calc(100svh - clamp(36px, 6vw, 96px))); min-height: 540px; display: grid; grid-template-rows: minmax(94px, .78fr) minmax(0, 4fr) minmax(76px, .62fr); gap: clamp(14px, 2.2vh, 24px); }
.message-panel { min-height: 0; display: grid; align-items: center; padding: clamp(18px, 2.8vw, 34px); border: 1px dashed #55555b; border-radius: 20px; background: #151515; }
.message { margin: 0; color: #fff; font-size: clamp(1.8rem, 4vw, 3.65rem); font-weight: 500; line-height: 1.12; letter-spacing: -.045em; overflow-wrap: anywhere; }
.message.empty { color: #8e8e93; }

.keyboard-panel { min-height: 0; display: flex; flex-direction: column; }
.keyboard-title { flex: none; margin: 0 0 13px; color: #a1a1a6; font-size: .78rem; font-weight: 650; letter-spacing: .04em; text-align: center; text-transform: uppercase; }
.keyboard-grid { flex: 1; min-height: 0; display: grid; gap: clamp(12px, 1.7vw, 20px); }
.group-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: repeat(3, minmax(0, 1fr)); }
.letter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(2, minmax(0, 1fr)); max-width: 760px; width: 100%; margin: 0 auto; }
.key-tile { position: relative; min-width: 0; min-height: 0; border: 1px solid #404045; border-radius: clamp(16px, 2vw, 24px); background: #1c1c1e; color: #f5f5f7; box-shadow: inset 0 1px #ffffff12; font-size: clamp(1.45rem, 4vw, 3.65rem); font-weight: 600; letter-spacing: -.04em; transition: border-color .14s ease, box-shadow .14s ease, background .14s ease, scale .14s ease; }
.letter-grid .key-tile { font-size: clamp(1.65rem, 5vw, 4.5rem); }
.letter-grid .key-tile:last-child, .key-tile.action-key { color: #c7c7cc; font-size: clamp(.8rem, 1.7vw, 1.1rem); letter-spacing: .08em; }
.key-tile.gaze-focus { z-index: 1; border-color: #fff; background: #28282a; box-shadow: 0 0 0 2px #ffffff80, 0 0 30px #ffffff42, inset 0 1px #ffffff29; scale: .985; }
.key-tile:focus-visible, .speak-button:focus-visible, .start-button:focus-visible, .quiet-button:focus-visible { outline: 3px solid #fff; outline-offset: 4px; }

/* DELETE and Speak share the bottom row. Speak takes twice the width: it is the
   larger commitment and the one hunted for in a hurry, and on the letter board
   DELETE is absent entirely, so Speak simply fills the row. */
.action-row { min-height: 0; display: flex; gap: clamp(12px, 1.7vw, 20px); }
.action-key { flex: 1 1 0; }
.speak-button { flex: 2 1 0; border: 1px solid #fff; border-radius: 20px; background: #fff; color: #111; font-size: clamp(1.15rem, 2.7vw, 1.7rem); font-weight: 690; letter-spacing: -.02em; }
.speak-button:disabled { cursor: wait; opacity: .75; }
.speak-button.gaze-focus { box-shadow: 0 0 0 3px #ffffff7a, 0 0 34px #ffffff5c; scale: .99; }

.gaze-cursor { pointer-events: none; position: fixed; z-index: 10; width: 18px; height: 18px; margin: -9px 0 0 -9px; border: 2px solid #ffffffcc; border-radius: 999px; box-shadow: 0 0 10px #ffffff70; transition: transform .05s linear; }
.dwell-orb { pointer-events: none; position: fixed; z-index: 11; translate: -50% -50%; border-radius: 50%; background: conic-gradient(from -90deg, #fff var(--progress, 0%), #ffffff26 0); filter: drop-shadow(0 0 13px #ffffff7a); -webkit-mask: radial-gradient(circle, #0000 57%, #000 58%); mask: radial-gradient(circle, #0000 57%, #000 58%); }
.calibration-overlay { position: fixed; z-index: 30; inset: 0; background: #111111f2; }
.calibration-copy { position: absolute; z-index: 1; top: 30px; left: 50%; width: min(520px, calc(100% - 40px)); translate: -50% 0; text-align: center; }
.calibration-copy p { margin: 0; color: #f5f5f7; font-size: 1rem; }
#calibration-step { margin-bottom: 9px; color: #a1a1a6; font-size: .74rem; font-weight: 700; letter-spacing: .14em; }
.calibration-target { position: fixed; width: 54px; height: 54px; margin: -27px 0 0 -27px; border: 3px solid #fff; border-radius: 50%; box-shadow: 0 0 0 10px #ffffff19, 0 0 28px #fff; animation: target-pulse 1.2s ease-in-out infinite; }
/* The ring only appears once readings are being taken, so the wait beforehand reads
   as the app waiting for the eye to settle rather than as the app doing nothing. */
.calibration-target.sampling { animation: none; }
.calibration-target.sampling::after { content: ''; position: absolute; inset: -17px; border-radius: 50%; background: conic-gradient(from -90deg, #9fe870 var(--progress, 0%), #ffffff1f 0); -webkit-mask: radial-gradient(circle, #0000 68%, #000 69%); mask: radial-gradient(circle, #0000 68%, #000 69%); }
.trace-canvas { position: fixed; z-index: 0; inset: 0; pointer-events: none; }
.trace-target, .trace-gaze { position: fixed; pointer-events: none; border-radius: 50%; translate: -50% -50%; }
.trace-target { z-index: 3; width: 28px; height: 28px; border: 3px solid #fff; background: #111; box-shadow: 0 0 0 9px #ffffff18, 0 0 24px #fff; }
.trace-gaze { z-index: 2; width: 20px; height: 20px; border: 2px solid #a1a1a6; box-shadow: 0 0 14px #ffffff88; }
.toast { position: fixed; z-index: 40; bottom: 28px; left: 50%; max-width: min(620px, calc(100% - 32px)); translate: -50% 0; padding: 11px 15px; border: 1px solid #4b4b50; border-radius: 12px; background: #252527; color: #f5f5f7; font-size: .91rem; text-align: center; }
@keyframes target-pulse { 50% { scale: 1.16; opacity: .74; } }

@media (max-width: 640px) {
  .app-shell { padding: 18px 14px; }
  .communicator { height: auto; min-height: calc(100svh - 36px); grid-template-rows: auto minmax(380px, 1fr) 78px; }
  .message-panel { min-height: 110px; }
  .group-grid { gap: 10px; }
  .key-tile { border-radius: 16px; }
}

/* Diagnostics only, and off by default: the board itself stays as bare as it was. */
.hud {
  position: fixed;
  left: 12px;
  top: 12px;
  max-width: calc(100vw - 24px);
  overflow: hidden;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.72);
  color: #9fe870;
  font: 500 11px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.02em;
  white-space: nowrap;
  pointer-events: none;
  z-index: 40;
}
