    /*
     * AACAI Eye Gaze Prototype
     * Design informed by AAC research:
     * - Target sizes >= 80px (research: 256x256px optimal for eye gaze, Namnakani et al. CHI 2025)
     * - Dwell time 1000ms default for novice users (600ms optimal, 500-1000ms range)
     * - Visual dwell feedback via contracting ring (Microsoft Mixed Reality guidelines)
     * - Core vocabulary (~100 words = ~50% daily communication)
     * - High contrast design for CVI accommodations
     * - Generous spacing to prevent Midas Touch accidental selections
     */

    :root {
     --bg: #1a1d23;
     --surface: #23272f;
     --surface-hover: #2d323c;
     --surface-active: #1a6b5a;
     --border: #353a45;
     --text-primary: #f0f2f5;
     --text-secondary: #a0a6b2;
     --text-muted: #6b7280;
     --accent: #34d399;
     --accent-dark: #1a6b5a;
     --accent-glow: rgba(52, 211, 153, 0.15);
     --danger: #ef4444;
     --danger-hover: #dc2626;
     --warning: #f59e0b;
     /* Modified Fitzgerald Key color coding (AAC standard) */
     --category-people: #facc15;    /* Yellow - pronouns/people */
     --category-actions: #4ade80;   /* Green - verbs */
     --category-describe: #60a5fa;  /* Blue - adjectives/descriptors */
     --category-feelings: #fb7185;  /* Pink - feelings/emotions */
     --category-questions: #c084fc; /* Purple - question words */
     --category-things: #fb923c;    /* Orange - nouns */
     --category-social: #f9a8d4;    /* Light pink - social/interjections */
     --category-phrases: #fbbf24;   /* Amber - phrases */
     --category-body: #f97316;      /* Deep orange - body parts */
     --dwell-time: 1000ms;
     --btn-size: 110px;
     --grid-gap: 6px;
     --grid-columns: 6;
     --radius: 10px;
    }

    * { margin: 0; padding: 0; box-sizing: border-box; }

    body {
      background: var(--bg);
      font-family: 'IBM Plex Sans', -apple-system, sans-serif;
      color: var(--text-primary);
      overflow: hidden;
      height: 100vh;
      width: 100vw;
     -webkit-font-smoothing: antialiased;
      user-select: none;
      cursor: none;
    }

    body.show-cursor { cursor: default; }
    body.show-cursor .word-btn,
    body.show-cursor .prediction-btn,
    body.show-cursor .category-tab,
    body.show-cursor .msg-action,
    body.show-cursor .header-btn,
    body.show-cursor .calibration-dot { cursor: pointer; }

    .welcome-overlay { cursor: default; }
    .welcome-overlay .welcome-start-btn { cursor: pointer; }

    /* Gaze cursor indicator */
    #gaze-cursor {
      position: fixed;
      width: 28px;
      height: 28px;
      border: 2px solid var(--accent);
      border-radius: 50%;
      pointer-events: none;
      z-index: 10000;
      transform: translate(-50%, -50%);
      transition: left 0.08s ease-out, top 0.08s ease-out, width 0.15s, height 0.15s, border-color 0.15s, box-shadow 0.15s;
      box-shadow: 0 0 12px var(--accent-glow);
    }

    #gaze-cursor.snapped {
      width: 36px;
      height: 36px;
      border-color: #a78bfa;
      box-shadow: 0 0 18px rgba(139, 92, 246, 0.5);
    }

    #gaze-cursor::after {
      content: '';
      position: absolute;
      top: 50%;
      left: 50%;
      width: 4px;
      height: 4px;
      background: var(--accent);
      border-radius: 50%;
      transform: translate(-50%, -50%);
    }

    /* App layout */
    .app {
      display: grid;
      grid-template-rows: auto auto auto 1fr auto;
      height: 100vh;
      gap: 4px;
      padding: 6px;
    }

    /* Header bar */
    .header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 6px 12px;
      background: var(--surface);
      border-radius: var(--radius);
    }

    .header-logo {
      font-weight: 600;
      font-size: 0.85rem;
      color: var(--text-primary);
      letter-spacing: -0.01em;
    }

    .header-logo span { color: var(--accent); }

    .header-controls {
      display: flex;
      gap: 6px;
    }

    .header-btn {
      background: var(--surface-hover);
      border: 1px solid var(--border);
      color: var(--text-secondary);
      padding: 6px 14px;
      border-radius: 6px;
      font-size: 0.78rem;
      font-family: inherit;
      cursor: none;
      transition: background 0.15s, color 0.15s;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      line-height: 1;
    }

    .header-btn:hover {
      background: var(--border);
      color: var(--text-primary);
    }

    .header-btn.active {
      background: var(--accent-dark);
      border-color: var(--accent);
      color: var(--accent);
    }

    /* Message bar - sentence display area */
    .message-bar {
      display: flex;
      align-items: center;
      gap: 6px;
      padding: 8px;
      background: var(--surface);
      border-radius: var(--radius);
      min-height: 72px;
    }

    .message-display {
      flex: 1;
      font-size: 1.35rem;
      font-weight: 400;
      color: var(--text-primary);
      padding: 8px 14px;
      background: rgba(0,0,0,0.2);
      border-radius: 8px;
      min-height: 52px;
      display: flex;
      align-items: center;
      flex-wrap: wrap;
      gap: 4px;
      line-height: 1.4;
    }

    .message-display .word {
      display: inline-block;
    }

    .message-display .cursor-blink {
      display: inline-block;
      width: 2px;
      height: 1.3em;
      background: var(--accent);
      animation: blink 1s step-end infinite;
      vertical-align: text-bottom;
      margin-left: 2px;
    }

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

    /* Message action buttons */
    .msg-action {
      width: 120px;
      height: 92px;
      border: 1px solid var(--border);
      border-radius: 8px;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 4px;
      font-size: 1rem;
      font-family: inherit;
      font-weight: 500;
      cursor: none;
      transition: all 0.15s;
      position: relative;
      overflow: hidden;
      color: var(--text-secondary);
      background: var(--surface-hover);
    }

    .msg-action svg {
      width: 30px;
      height: 30px;
      stroke: currentColor;
      fill: none;
      stroke-width: 2;
      stroke-linecap: round;
      stroke-linejoin: round;
      z-index: 1;
      position: relative;
    }

    .msg-action > span {
      z-index: 1;
      position: relative;
    }

    .msg-action.speak-btn {
      background: var(--accent-dark);
      border-color: var(--accent);
      color: var(--accent);
      width: 130px;
    }

    .msg-action.speak-btn:hover {
      border-color: var(--accent);
    }

    .msg-action.speak-btn.selected {
      background: var(--accent);
      color: var(--bg);
      animation: selectPulse 0.3s ease-out;
    }

    .msg-action.speak-btn .dwell-overlay {
      background: rgba(52, 211, 153, 0.25);
    }

    .msg-action.speak-btn.dwelling .dwell-border {
      border-color: var(--accent);
    }

    .msg-action.clear-btn:hover {
      border-color: var(--danger);
    }

    .msg-action.clear-btn.selected {
      background: var(--danger);
      border-color: var(--danger);
      color: white;
      animation: selectPulse 0.3s ease-out;
    }

    .msg-action.clear-btn .dwell-overlay {
      background: rgba(239, 68, 68, 0.25);
    }

    .msg-action.clear-btn.dwelling .dwell-border {
      border-color: var(--danger);
    }

    .msg-action.backspace-btn:hover {
      border-color: var(--warning);
    }

    .msg-action.backspace-btn.selected {
      background: var(--warning);
      border-color: var(--warning);
      color: var(--bg);
      animation: selectPulse 0.3s ease-out;
    }

    .msg-action.backspace-btn .dwell-overlay {
      background: rgba(245, 158, 11, 0.25);
    }

    .msg-action.backspace-btn.dwelling .dwell-border {
      border-color: var(--warning);
    }

    .msg-action.period-btn .period-symbol {
      font-size: 2rem;
      font-weight: 700;
      line-height: 1;
      z-index: 1;
      position: relative;
    }

    /* Dwell progress ring on all interactive elements */
    .dwell-ring {
      position: absolute;
      inset: 0;
      pointer-events: none;
      opacity: 0;
      z-index: 2;
    }

    .dwell-ring svg {
      width: 100%;
      height: 100%;
    }

    .dwell-ring circle {
      fill: none;
      stroke: var(--accent);
      stroke-width: 3;
      stroke-dasharray: 300;
      stroke-dashoffset: 300;
    }

    /* Prediction bar */
    .prediction-bar {
      display: flex;
      gap: 6px;
      padding: 6px 0;
      min-height: 100px;
      align-items: stretch;
    }

    .prediction-btn {
      flex: 1;
      min-height: 92px;
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 8px;
      color: var(--text-primary);
      font-family: inherit;
      font-size: 1.45rem;
      font-weight: 500;
      cursor: none;
      position: relative;
      overflow: hidden;
      transition: all 0.15s;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 6px 14px;
    }

    .prediction-btn:hover {
      background: var(--surface-hover);
      border-color: var(--accent);
    }

    .prediction-btn.active {
      background: var(--accent-dark);
      border-color: var(--accent);
    }

    .prediction-btn .pred-rank {
      position: absolute;
      top: 4px;
      left: 8px;
      font-size: 0.6rem;
      color: var(--text-muted);
      font-weight: 400;
      z-index: 1;
    }

    .prediction-btn .pred-source {
      position: absolute;
      bottom: 3px;
      right: 8px;
      font-size: 0.55rem;
      color: var(--text-muted);
      font-weight: 400;
      letter-spacing: 0.02em;
      z-index: 1;
    }

    .prediction-btn.ai-prediction {
      border-color: rgba(139, 92, 246, 0.5);
      background: rgba(139, 92, 246, 0.08);
    }

    .prediction-btn.ai-prediction .pred-source {
      color: #a78bfa;
    }

    .prediction-btn.ai-prediction:hover {
      border-color: #a78bfa;
      background: rgba(139, 92, 246, 0.15);
    }

    .prediction-btn.spell-completion {
      border-color: rgba(148, 163, 184, 0.4);
      background: rgba(148, 163, 184, 0.08);
    }

    .prediction-btn.spell-completion .pred-prefix {
      color: var(--accent);
      font-weight: 600;
    }

    .prediction-btn.spell-completion .pred-source {
      color: #94a3b8;
    }

    .prediction-btn.spell-completion:hover {
      border-color: #94a3b8;
      background: rgba(148, 163, 184, 0.18);
    }

    .prediction-btn.spell-completion.ai-prediction {
      border-color: rgba(139, 92, 246, 0.4);
      background: rgba(139, 92, 246, 0.08);
    }

    .prediction-btn.spell-completion.ai-prediction:hover {
      border-color: #a78bfa;
      background: rgba(139, 92, 246, 0.15);
    }

    /* Main grid area */
    .grid-area {
      display: flex;
      flex-direction: column;
      gap: 4px;
      overflow: hidden;
    }

    /* Category tabs */
    .category-tabs {
      display: flex;
      gap: 4px;
      padding: 2px 0;
      flex-shrink: 0;
    }

    .category-tab {
      flex: 1;
      height: 88px;
      border: 1px solid var(--border);
      border-radius: 8px;
      background: var(--surface);
      color: var(--text-secondary);
      font-family: inherit;
      font-size: 1.15rem;
      font-weight: 500;
      cursor: none;
      position: relative;
      overflow: hidden;
      transition: all 0.15s;
      text-transform: uppercase;
      letter-spacing: 0.06em;
    }

    .category-tab:hover {
      background: var(--surface-hover);
    }

    .category-tab.active {
      color: var(--text-primary);
      font-weight: 600;
    }

    .category-tab.active[data-category="people"] { background: var(--category-people); color: #1a1d23; border-color: var(--category-people); }
    .category-tab.active[data-category="actions"] { background: var(--category-actions); color: #1a1d23; border-color: var(--category-actions); }
    .category-tab.active[data-category="describe"] { background: var(--category-describe); color: #fff; border-color: var(--category-describe); }
    .category-tab.active[data-category="feelings"] { background: var(--category-feelings); color: #1a1d23; border-color: var(--category-feelings); }
    .category-tab.active[data-category="questions"] { background: var(--category-questions); color: #fff; border-color: var(--category-questions); }
    .category-tab.active[data-category="things"] { background: var(--category-things); color: #1a1d23; border-color: var(--category-things); }
    .category-tab.active[data-category="social"] { background: var(--category-social); color: #1a1d23; border-color: var(--category-social); }
    .category-tab.active[data-category="phrases"] { background: var(--category-phrases); color: #1a1d23; border-color: var(--category-phrases); }
    .category-tab.active[data-category="spell"] { background: #94a3b8; color: #1a1d23; border-color: #94a3b8; }

    /* Spell grid - keyboard layout */
    .word-grid.spell-grid {
      grid-template-columns: repeat(10, 1fr);
    }

    .word-btn.spell-key {
      min-height: 82px;
      font-size: 1.5rem;
      font-weight: 600;
    }

    .word-btn.spell-key.wide-key {
      grid-column: span 2;
      font-size: 0.95rem;
    }

    /* Word grid - fixed column count so all buttons snap to equal width */
    .word-grid {
      display: grid;
      grid-template-columns: repeat(var(--grid-columns), 1fr);
      gap: var(--grid-gap);
      flex: 1;
      overflow-y: auto;
      overflow-x: hidden;
      padding: 2px;
      align-content: start;
    }

    .word-grid::-webkit-scrollbar { width: 6px; }
    .word-grid::-webkit-scrollbar-track { background: transparent; }
    .word-grid::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

    /* Word buttons - large targets for eye gaze (research: min 3.28x3.78cm) */
    .word-btn {
      min-height: var(--btn-size);
      background: var(--surface);
      border: 2px solid var(--border);
      border-radius: var(--radius);
      color: var(--text-primary);
      font-family: inherit;
      font-size: 1.05rem;
      font-weight: 500;
      cursor: none;
      position: relative;
      overflow: hidden;
      transition: background 0.12s, border-color 0.12s;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 2px;
      padding: 8px;
    }

    .word-btn:hover {
      background: var(--surface-hover);
      border-color: rgba(52, 211, 153, 0.4);
    }

    .word-btn.selected {
      background: var(--accent-dark);
      border-color: var(--accent);
      animation: selectPulse 0.3s ease-out;
    }

    @keyframes selectPulse {
      0% { box-shadow: 0 0 0 4px var(--accent-glow); }
      100% { box-shadow: 0 0 0 0 transparent; }
    }

    .word-btn .word-label {
      font-size: 1.05rem;
      font-weight: 600;
      z-index: 1;
      text-align: center;
      line-height: 1.2;
    }

    .word-btn .word-type {
      font-size: 0.55rem;
      color: var(--text-muted);
      text-transform: uppercase;
      letter-spacing: 0.08em;
      z-index: 1;
    }

    /* Color-coded left border by word type (Modified Fitzgerald Key) */
    .word-btn[data-type="pronoun"] { border-left: 4px solid var(--category-people); }
    .word-btn[data-type="verb"] { border-left: 4px solid var(--category-actions); }
    .word-btn[data-type="adjective"] { border-left: 4px solid var(--category-describe); }
    .word-btn[data-type="feeling"] { border-left: 4px solid var(--category-feelings); }
    .word-btn[data-type="question"] { border-left: 4px solid var(--category-questions); }
    .word-btn[data-type="noun"] { border-left: 4px solid var(--category-things); }
    .word-btn[data-type="social"] { border-left: 4px solid var(--category-social); }
    .word-btn[data-type="preposition"] { border-left: 4px solid var(--text-muted); }
    .word-btn[data-type="determiner"] { border-left: 4px solid var(--text-muted); }
    .word-btn[data-type="conjunction"] { border-left: 4px solid var(--text-muted); }
    .word-btn[data-type="adverb"] { border-left: 4px solid var(--category-describe); }
    .word-btn[data-type="negation"] { border-left: 4px solid var(--danger); }
    .word-btn[data-type="phrase"] { border-left: 4px solid var(--category-phrases); }

    /* Emergency button - always visible in header */
    .emergency-bar {
      display: flex;
      justify-content: center;
      padding: 4px 12px;
    }
    .emergency-btn {
      background: var(--danger) !important;
      border-color: var(--danger) !important;
      color: white !important;
      font-weight: 700 !important;
      font-size: 0.95rem;
      padding: 10px 22px;
      letter-spacing: 0.05em;
      position: relative;
      overflow: hidden;
      min-width: 200px;
    }
    .emergency-btn:hover {
      background: var(--danger-hover) !important;
    }

    /* Emergency grid - large buttons, 3-column layout */
    .word-grid.emergency-grid {
      grid-template-columns: repeat(3, 1fr) !important;
      grid-template-rows: repeat(4, 1fr);
      overflow-y: hidden;
    }
    .word-grid.emergency-grid .word-btn {
      min-height: 0;
      background: rgba(239, 68, 68, 0.08);
      border-color: rgba(239, 68, 68, 0.4);
      font-size: 1.1rem;
    }
    .word-grid.emergency-grid .word-btn:hover {
      background: rgba(239, 68, 68, 0.18);
      border-color: var(--danger);
    }
    .word-grid.emergency-grid .word-btn.selected {
      background: var(--danger);
      border-color: var(--danger);
    }
    .word-grid.emergency-grid .word-btn .dwell-overlay {
      background: rgba(239, 68, 68, 0.25);
    }
    .word-grid.emergency-grid .dwelling .dwell-border {
      border-color: var(--danger);
    }
    .word-grid.emergency-grid .emergency-back {
      background: var(--surface);
      border-color: var(--border);
    }
    .word-grid.emergency-grid .emergency-back:hover {
      background: var(--surface-hover);
      border-color: var(--accent);
    }
    .word-grid.emergency-grid .emergency-back .dwell-overlay {
      background: var(--accent-glow);
    }

    /* Fixed core grid - motor planning: words never move position */
    .word-grid.core-fixed {
      grid-template-columns: repeat(4, 1fr) !important;
      grid-template-rows: repeat(7, 1fr);
      overflow-y: hidden;
    }
    .word-grid.core-fixed .word-btn {
      min-height: 0;
      font-size: 1.25rem;
    }

    /* Dwell progress overlay - applies to all dwell-able buttons */
    .dwell-overlay {
      position: absolute;
      bottom: 0;
      left: 0;
      right: 0;
      height: 0%;
      background: var(--accent-glow);
      transition: none;
      pointer-events: none;
      z-index: 0;
    }

    .dwell-border {
      position: absolute;
      inset: -2px;
      border-radius: inherit;
      border: 3px solid transparent;
      pointer-events: none;
      z-index: 3;
    }

    .dwell-overlay {
      transition: height 60ms linear;
    }

    .dwelling .dwell-border {
      border-color: var(--accent);
    }

    /* Bottom status bar */
    .status-bar {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 4px 12px;
      background: var(--surface);
      border-radius: var(--radius);
      font-size: 0.68rem;
      color: var(--text-muted);
    }

    .status-left, .status-right {
      display: flex;
      align-items: center;
      gap: 16px;
    }

    .status-indicator {
      display: flex;
      align-items: center;
      gap: 4px;
    }

    .status-dot {
      width: 6px;
      height: 6px;
      border-radius: 50%;
      background: var(--accent);
    }

    .status-dot.warn { background: var(--warning); }

    /* Settings panel */
    .settings-overlay {
      position: fixed;
      inset: 0;
      background: rgba(0,0,0,0.6);
      z-index: 1000;
      display: none;
      align-items: center;
      justify-content: center;
    }

    .settings-overlay.open { display: flex; }

    .settings-panel {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 16px;
      padding: 32px;
      width: 480px;
      max-width: 90vw;
      max-height: 80vh;
      overflow-y: auto;
    }

    .settings-panel h2 {
      font-size: 1.1rem;
      font-weight: 600;
      margin-bottom: 24px;
      color: var(--text-primary);
    }

    .setting-group {
      margin-bottom: 20px;
    }

    .setting-group label {
      display: block;
      font-size: 0.8rem;
      font-weight: 500;
      color: var(--text-secondary);
      margin-bottom: 8px;
    }

    .setting-group .setting-desc {
      font-size: 0.7rem;
      color: var(--text-muted);
      margin-bottom: 8px;
    }

    .setting-group input[type="range"] {
      width: 100%;
      accent-color: var(--accent);
    }

    .setting-value {
      font-size: 0.78rem;
      color: var(--accent);
      font-weight: 600;
    }

    .setting-group select {
      width: 100%;
      padding: 8px 12px;
      background: var(--bg);
      border: 1px solid var(--border);
      border-radius: 6px;
      color: var(--text-primary);
      font-family: inherit;
      font-size: 0.85rem;
    }

    .settings-close {
      margin-top: 20px;
      width: 100%;
      padding: 12px;
      background: var(--accent-dark);
      border: 1px solid var(--accent);
      border-radius: 8px;
      color: var(--accent);
      font-family: inherit;
      font-size: 0.9rem;
      font-weight: 600;
      cursor: pointer;
    }

    .settings-close:hover {
      background: var(--accent);
      color: var(--bg);
    }

    /* Phrase buttons (wider) */
    .word-btn.phrase-btn {
      grid-column: span 2;
      font-size: 0.95rem;
    }

    /* Responsive */
    @media (max-width: 800px) {
      :root {
       --btn-size: 90px;
       --grid-gap: 4px;
      }
      .message-display { font-size: 1.1rem; }
      .category-tab { font-size: 0.95rem; height: 72px; }
    }

    /* Mobile gate */
    .mobile-gate {
      display: none;
      position: fixed;
      inset: 0;
      background: var(--bg);
      z-index: 99999;
      justify-content: center;
      align-items: center;
      text-align: center;
      padding: 24px;
      cursor: default;
    }
    .mobile-gate-link { cursor: pointer; }
    .mobile-gate-panel h2 {
      font-size: 1.5rem;
      font-weight: 600;
      color: var(--text-primary);
      margin-bottom: 16px;
    }
    .mobile-gate-panel h2 span { color: var(--accent); }
    .mobile-gate-panel p {
      font-size: 0.95rem;
      color: var(--text-secondary);
      line-height: 1.6;
      margin-bottom: 12px;
      max-width: 340px;
    }
    .mobile-gate-link {
      display: inline-block;
      margin-top: 12px;
      padding: 12px 24px;
      background: var(--accent-dark);
      border: 1px solid var(--accent);
      border-radius: 8px;
      color: var(--accent);
      text-decoration: none;
      font-weight: 600;
      font-size: 0.9rem;
    }

    @media (max-width: 900px) {
      .mobile-gate { display: flex; }
    }

    @media (max-width: 600px) {
      :root {
       --btn-size: 80px;
      }
      .header { padding: 4px 8px; }
      .message-bar { padding: 4px; min-height: 60px; }
      .msg-action { width: 100px; height: 80px; }
      .msg-action.speak-btn { width: 110px; }
    }

    /* High contrast mode */
    body.high-contrast {
     --bg: #000000;
     --surface: #111111;
     --surface-hover: #222222;
     --border: #555555;
     --text-primary: #ffffff;
     --text-secondary: #cccccc;
     --text-muted: #999999;
     --accent: #6ee7b7;
     --accent-dark: #1a6b5a;
     --accent-glow: rgba(110, 231, 183, 0.2);
    }

    body.high-contrast .word-btn {
      border-width: 3px;
      font-weight: 700;
    }

    /* Calibration overlay */
    .calibration-overlay {
      display: none;
      position: fixed;
      top: 0; left: 0; right: 0; bottom: 0;
      background: rgba(10, 12, 18, 0.95);
      z-index: 9999;
      justify-content: center;
      align-items: center;
    }
    .calibration-overlay.active {
      display: flex;
    }
    .calibration-dot {
      position: absolute;
      width: 32px;
      height: 32px;
      border-radius: 50%;
      background: var(--accent);
      opacity: 0.4;
      transform: translate(-50%, -50%) scale(1);
      transition: opacity 0.3s, transform 0.3s, box-shadow 0.3s;
      cursor: none;
    }
    .calibration-dot.active-dot {
      opacity: 1;
      transform: translate(-50%, -50%) scale(1.4);
      box-shadow: 0 0 24px var(--accent-glow), 0 0 48px var(--accent-glow);
    }
    .calibration-dot.completed {
      opacity: 0.15;
      transform: translate(-50%, -50%) scale(0.7);
      background: #888;
    }
    .calibration-dot .dot-ring {
      position: absolute;
      top: 50%; left: 50%;
      width: 48px; height: 48px;
      border: 2px solid var(--accent);
      border-radius: 50%;
      transform: translate(-50%, -50%);
      opacity: 0;
    }
    .calibration-dot.active-dot .dot-ring {
      opacity: 1;
      animation: calibration-pulse 1s ease-in-out infinite;
    }
    @keyframes calibration-pulse {
      0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0.6; }
      50% { transform: translate(-50%, -50%) scale(1.5); opacity: 0; }
    }
    .calibration-dot .dot-progress {
      position: absolute;
      top: 50%; left: 50%;
      width: 48px; height: 48px;
      transform: translate(-50%, -50%);
    }
    .calibration-dot .dot-progress circle {
      fill: none;
      stroke: var(--accent);
      stroke-width: 2;
      stroke-dasharray: 150.8;
      stroke-dashoffset: 150.8;
      transform: rotate(-90deg);
      transform-origin: center;
    }
    .calibration-dot.active-dot .dot-progress circle {
      transition: stroke-dashoffset linear;
    }
    .calibration-msg {
      position: absolute;
      top: 45%;
      left: 50%;
      transform: translate(-50%, -50%);
      color: var(--text-primary);
      font-size: 1.3rem;
      text-align: center;
      pointer-events: none;
    }
    .calibration-instruction {
      position: absolute;
      bottom: 12%;
      left: 50%;
      transform: translateX(-50%);
      color: var(--text-muted);
      font-size: 0.9rem;
      text-align: center;
      pointer-events: none;
    }

    /* Welcome modal */
    .welcome-overlay {
      display: none;
      position: fixed;
      inset: 0;
      background: rgba(10, 12, 18, 0.95);
      z-index: 10001;
      justify-content: center;
      align-items: center;
    }
    .welcome-overlay.active { display: flex; }
    .welcome-panel {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 16px;
      padding: 36px 32px;
      max-width: 480px;
      width: 90vw;
      text-align: center;
    }
    .welcome-panel h2 {
      font-size: 1.3rem;
      font-weight: 600;
      margin-bottom: 6px;
      color: var(--text-primary);
    }
    .welcome-panel h2 span { color: var(--accent); }
    .welcome-panel .welcome-subtitle {
      font-size: 0.85rem;
      color: var(--text-secondary);
      margin-bottom: 8px;
    }
    .welcome-panel .welcome-device-note {
      font-size: 0.72rem;
      color: var(--text-muted);
      margin-bottom: 20px;
      line-height: 1.5;
    }
    .welcome-steps {
      text-align: left;
      display: flex;
      flex-direction: column;
      gap: 0;
      margin-bottom: 20px;
    }
    .welcome-step {
      display: flex;
      align-items: flex-start;
      gap: 14px;
      padding: 14px 0;
      border-bottom: 1px solid var(--border);
    }
    .welcome-step:last-child { border-bottom: none; }
    .welcome-step-num {
      flex-shrink: 0;
      width: 28px;
      height: 28px;
      border-radius: 50%;
      background: var(--accent-dark);
      color: var(--accent);
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 0.75rem;
      font-weight: 600;
      margin-top: 1px;
    }
    .welcome-step-content {
      flex: 1;
      min-width: 0;
    }
    .welcome-step-title {
      font-size: 0.88rem;
      font-weight: 600;
      color: var(--text-primary);
      margin-bottom: 3px;
    }
    .welcome-step-title .key-tag {
      display: inline-block;
      padding: 1px 7px;
      border-radius: 4px;
      font-size: 0.65rem;
      font-weight: 600;
      vertical-align: middle;
      margin-left: 6px;
    }
    .key-tag.optional { background: rgba(255,255,255,0.06); color: var(--text-muted); }
    .welcome-step-desc {
      font-size: 0.78rem;
      color: var(--text-secondary);
      line-height: 1.55;
    }
    .welcome-keys {
      display: flex;
      flex-direction: column;
      gap: 8px;
      margin-top: 10px;
    }
    .welcome-key-row {
      display: flex;
      align-items: center;
      gap: 6px;
    }
    .welcome-key-input {
      flex: 1;
      min-width: 0;
      padding: 7px 10px;
      background: var(--bg);
      border: 1px solid var(--border);
      border-radius: 6px;
      color: var(--text-primary);
      font-family: inherit;
      font-size: 0.78rem;
    }
    .welcome-key-input::placeholder { color: var(--text-muted); }
    .welcome-key-input:focus { border-color: var(--accent); outline: none; }
    .welcome-key-save {
      flex-shrink: 0;
      padding: 7px 14px;
      background: var(--accent-dark);
      border: 1px solid var(--accent);
      border-radius: 6px;
      color: var(--accent);
      font-family: inherit;
      font-size: 0.75rem;
      font-weight: 600;
      cursor: pointer;
      transition: background 0.15s;
    }
    .welcome-key-save:hover { background: var(--accent); color: var(--bg); }
    .welcome-key-check {
      flex-shrink: 0;
      width: 20px;
      font-size: 0.85rem;
      text-align: center;
    }
    .welcome-start-btn {
      width: 100%;
      padding: 14px;
      background: var(--accent-dark);
      border: 1px solid var(--accent);
      border-radius: 8px;
      color: var(--accent);
      font-family: inherit;
      font-size: 1rem;
      font-weight: 600;
      cursor: pointer;
      transition: background 0.15s, color 0.15s;
    }
    .welcome-start-btn:hover {
      background: var(--accent);
      color: var(--bg);
    }
    .welcome-enter-hint {
      font-size: 0.72rem;
      color: var(--text-muted);
      margin-top: 10px;
    }

    /* Help overlay */
    .help-overlay {
      display: none;
      position: fixed;
      inset: 0;
      background: rgba(0,0,0,0.6);
      z-index: 1000;
      align-items: center;
      justify-content: center;
    }
    .help-overlay.open { display: flex; }
    .help-panel {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 16px;
      padding: 32px;
      width: 420px;
      max-width: 90vw;
      max-height: 80vh;
      overflow-y: auto;
    }
    .help-panel h2 {
      font-size: 1.1rem;
      font-weight: 600;
      margin-bottom: 20px;
      color: var(--text-primary);
    }
    .help-shortcut {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 8px 0;
      border-bottom: 1px solid var(--border);
      font-size: 0.82rem;
    }
    .help-shortcut:last-child { border-bottom: none; }
    .help-shortcut span:first-child { color: var(--text-secondary); }
    .help-key {
      display: inline-block;
      padding: 2px 8px;
      background: var(--bg);
      border: 1px solid var(--border);
      border-radius: 4px;
      font-size: 0.75rem;
      font-weight: 600;
      color: var(--text-primary);
      font-family: inherit;
    }
