.virtual-keyboard {
  flex-shrink: 0;
  background: var(--bg-secondary);
  backdrop-filter: blur(var(--blur-amount));
  -webkit-backdrop-filter: blur(var(--blur-amount));
  border-top: 1px solid var(--border-color);
  padding: 6px 10px 2px;
  touch-action: none;
}

.key-row {
  display: flex;
  gap: 6px;
  margin-bottom: 5px;
  align-items: center;
}

.key-row:last-child {
  margin-bottom: 0;
}

/* ── Physical key style ──────────────────────────── */
.key {
  flex: 0 0 auto;
  min-width: 44px;
  height: 42px;
  border: 1px solid var(--key-border);
  border-bottom: 2px solid var(--key-depth);
  border-radius: var(--radius-xs);
  background: var(--key-bg);
  background-image: linear-gradient(180deg, var(--key-bg-highlight) 0%, transparent 60%);
  color: var(--text-primary);
  font-size: 0.88rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 7px;
  -webkit-user-select: none;
  user-select: none;
  transition: background var(--transition-fast), transform var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.key:active {
  background: var(--key-active-bg);
  background-image: none;
  border-bottom-width: 1px;
  transform: translateY(1px);
}

.key.modifier {
  font-weight: 600;
  font-size: 0.8rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.key.modifier.active {
  background: var(--accent);
  background-image: var(--accent-gradient);
  color: #fff;
  border-color: transparent;
  border-bottom-color: var(--accent-dim);
  box-shadow: 0 0 14px var(--accent-glow);
}

.key.modifier.locked {
  background: var(--accent);
  background-image: var(--accent-gradient);
  color: #fff;
  border-color: transparent;
  border-bottom-color: var(--accent-dim);
  box-shadow: 0 0 0 2px var(--accent-hover), 0 0 20px var(--accent-glow);
}

.key.shortcut {
  font-family: 'SF Mono', 'JetBrains Mono', 'Menlo', monospace;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-secondary);
  min-width: 40px;
}

.key-spacer {
  flex: 1;
}

/* ── Input row — pill style ──────────────────────── */
.input-row {
  gap: 6px;
}

.text-input {
  flex: 1;
  height: 44px;
  min-height: 44px;
  max-height: 44px;
  border: 1px solid var(--border-color);
  border-radius: 22px;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 1rem;
  padding: 11px 18px;
  line-height: 20px;
  outline: none;
  resize: none;
  overflow-y: auto;
  font-family: 'SF Mono', 'JetBrains Mono', 'Menlo', monospace;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.text-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.text-input::placeholder {
  color: var(--text-dimmed);
}

.send-key {
  width: 44px;
  height: 44px;
  min-width: unset;
  padding: 0;
  flex-shrink: 0;
  border-radius: var(--radius-pill);
  background: var(--accent);
  background-image: var(--accent-gradient);
  color: #fff;
  border: none;
  border-bottom: none;
  font-size: 1.05rem;
  font-weight: 700;
  box-shadow: 0 2px 10px var(--accent-glow);
}

.send-key:active {
  background-image: none;
  background: var(--accent-dim);
  transform: scale(0.92);
  box-shadow: none;
}

/* ── Landscape ───────────────────────────────────── */
@media (max-height: 500px) {
  .key {
    height: 32px;
    min-width: 36px;
    font-size: 0.75rem;
  }
  .text-input, .send-key {
    height: 34px;
  }
  .text-input {
    min-height: 34px;
    max-height: 34px;
    padding: 7px 14px;
    border-radius: 17px;
  }
  .virtual-keyboard {
    padding: 5px 6px 4px;
  }
  .key-row {
    gap: 4px;
    margin-bottom: 4px;
  }
}

/* ── Desktop ─────────────────────────────────────── */
@media (min-width: 1024px) {
  .virtual-keyboard {
    padding: 10px 20px;
  }

  .key {
    min-width: 46px;
    height: 34px;
  }

  .key:hover {
    background-image: none;
    background: var(--key-active-bg);
    border-color: var(--accent);
  }

  .text-input {
    max-width: 640px;
  }

  .send-key:hover {
    filter: brightness(1.12);
    box-shadow: 0 4px 16px var(--accent-glow);
  }

  .text-input { max-width: unset; }
  .key-row.all-keys { overflow: visible; }
}

.key-row.all-keys {
  overflow-x: auto;
  flex-wrap: nowrap;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  touch-action: pan-x;
}
.key-row.all-keys::-webkit-scrollbar { display: none; }
.key-row.all-keys .key.shortcut { min-width: 32px; padding: 0 5px; }

.key.claude-codex-only { display: none; }
body.claude-mode .key.claude-codex-only,
body.codex-mode .key.claude-codex-only { display: flex; }

.keyboard-toggle {
  width: 44px;
  height: 44px;
  min-width: unset;
  flex-shrink: 0;
  padding: 0;
  border: 1px solid var(--key-border);
  border-bottom: 2px solid var(--key-depth);
  border-radius: var(--radius-pill);
  background: var(--key-bg);
  background-image: linear-gradient(180deg, var(--key-bg-highlight) 0%, transparent 60%);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-user-select: none;
  user-select: none;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.keyboard-toggle:active {
  background: var(--key-active-bg);
  background-image: none;
  border-bottom-width: 1px;
  transform: translateY(1px);
}

.virtual-keyboard.collapsed .keyboard-toggle {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: var(--accent);
}

.virtual-keyboard.collapsed .key-row:not(.input-row) { display: none; }