:root {
  --bg-primary: #000000;
  --bg-secondary: #0a0a0f;
  --bg-tertiary: #14141f;
  --bg-card: #1a1a2e;
  --text-primary: #ffffff;
  --text-secondary: #a0a0b0;
  --text-muted: #606070;
  --accent-primary: #00d4ff;
  --accent-secondary: #00ff88;
  --accent-warm: #ff9f43;
  --danger: #ff4466;
  --focus-ring: #00d4ff;
  --focus-glow: rgba(0, 212, 255, 0.4);
  --success: #00ff88;
  --warning: #ffaa00;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  width: 600px;
  height: 600px;
  overflow: hidden;
}

body.phone-mode {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  min-height: 100vh;
  min-height: 100dvh;
}
body.phone-mode #app { width: 100%; height: 100%; }
body.phone-mode .screen:not(#phone):not(#permission):not(#question) { display: none !important; }

#app {
  width: 100%;
  height: 100%;
  position: relative;
}

.screen {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  position: absolute;
  top: 0;
  left: 0;
}
.screen.hidden { display: none; }

.header {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  background: var(--bg-secondary);
  gap: 12px;
  flex-shrink: 0;
}
.header h1 {
  font-size: 22px;
  font-weight: 600;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.session-header-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.session-header-text h1 { flex: 0 0 auto; }
.session-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  font-family: 'Consolas', 'Menlo', monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.session-pin {
  display: inline-block;
  font-size: 14px;
  margin-right: 4px;
  cursor: pointer;
  vertical-align: middle;
}
.nav-reload {
  flex: 0 0 auto !important;
  min-width: 52px;
  font-size: 18px;
}
.header-meta {
  font-size: 13px;
  color: var(--text-secondary);
  flex-shrink: 0;
}
.header-meta.busy { color: var(--accent-warm); }
.header-meta.idle { color: var(--text-secondary); }
.header-meta.error { color: var(--danger); }
.header-meta.session-target {
  max-width: 180px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--accent-primary);
  font-size: 12px;
}
.back-btn {
  background: transparent;
  color: var(--text-primary);
  font-size: 22px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
}

.content {
  flex: 1;
  padding: 16px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}

.focusable {
  transition: all 0.15s ease;
  border: 2px solid transparent;
  cursor: pointer;
  min-height: 44px;
}
.focusable:focus {
  outline: none;
  border-color: var(--focus-ring);
  box-shadow: 0 0 20px var(--focus-glow);
}

.nav-bar {
  display: flex;
  gap: 8px;
  padding: 12px 20px;
  background: var(--bg-secondary);
  flex-shrink: 0;
}
.nav-item {
  flex: 1;
  padding: 14px 16px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 500;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.nav-item:focus { background: var(--bg-card); }
.nav-item.primary {
  background: var(--accent-primary);
  color: #0a0a0f;
}
.nav-item.primary:focus { background: #33ddff; }

/* --- Setup screen --- */
.setup-content { gap: 16px; }
.setup-text { font-size: 18px; color: var(--text-primary); }
.setup-text-muted { font-size: 14px; color: var(--text-secondary); }
.setup-field { display: flex; flex-direction: column; gap: 8px; margin: 18px 0; color: #ddd; font-size: 16px; }
.setup-field .prompt-input { flex: none; width: 100%; box-sizing: border-box; }
.setup-code {
  display: block;
  font-family: 'Consolas', 'Menlo', monospace;
  font-size: 14px;
  background: var(--bg-tertiary);
  padding: 12px;
  border-radius: var(--radius-sm);
  color: var(--accent-primary);
  word-break: break-all;
}
.setup-hint { font-size: 12px; }

/* --- Messages list (Conversation View) --- */
.messages-content { padding: 12px 16px; }
.messages-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.message {
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
  font-size: 15px;
  line-height: 1.4;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.message-role {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text-secondary);
}
.message.user .message-role { color: var(--accent-secondary); }
.message.user { background: var(--bg-card); }
.message.assistant .message-role { color: var(--accent-primary); }
.message.tool {
  background: transparent;
  border-left: 3px solid var(--accent-warm);
  border-radius: 0;
  padding: 4px 12px;
  font-size: 13px;
  color: var(--text-secondary);
  font-family: 'Consolas', 'Menlo', monospace;
}
.message.tool .message-role { color: var(--accent-warm); }
.message.system {
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
  padding: 4px;
}
.message.error {
  background: rgba(255, 68, 102, 0.15);
  border-left: 3px solid var(--danger);
  color: var(--danger);
  font-size: 14px;
  font-family: 'Consolas', 'Menlo', monospace;
}
.message.error .message-role { color: var(--danger); }

.msg-screenshot {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 8px 0 2px;
  border-radius: 8px;
  border: 1px solid var(--bg-tertiary);
}
.messages-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 20px;
}

/* --- Sessions list --- */
.sessions-content { padding: 12px 16px; }
.sessions-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.session-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  text-align: left;
  width: 100%;
}
.session-item:focus { background: var(--bg-card); }
.session-item.active {
  border-left: 3px solid var(--accent-primary);
  background: var(--bg-card);
}
.session-item-title {
  font-size: 15px;
  font-weight: 500;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 8px;
}
.session-status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}
.session-status-dot.busy { background: var(--accent-warm); }
.session-status-dot.idle { background: var(--text-secondary); }
.session-item-meta {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: 'Consolas', 'Menlo', monospace;
}
.session-item.active .session-item-title::after {
  content: '✓';
  color: var(--accent-primary);
  margin-left: auto;
  font-weight: 600;
}
.session-item.action-row {
  border: 1px dashed var(--text-secondary);
  background: var(--bg-card);
}
.session-item.action-row:focus { border-color: var(--focus-ring); }

/* --- Hub screens (Computers / Agents / Projects) --- */
.header-refresh { flex: 0 0 auto; padding: 6px 12px; font-size: 13px; min-height: 36px; }
.hub-content { padding: 12px 16px; }
.hub-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.hub-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  text-align: left;
  width: 100%;
}
.hub-item:focus { background: var(--bg-card); }
.hub-item.active { border-left: 3px solid var(--accent-primary); background: var(--bg-card); }
.hub-item.unavailable { opacity: 0.55; }
.hub-item.action-row { border: 1px dashed var(--text-secondary); background: var(--bg-card); }
.hub-item.auto-row.on { border: 1px solid var(--success); }
.hub-item.auto-row.on .hub-item-meta { color: var(--success); }
.hub-item-title {
  font-size: 15px;
  font-weight: 500;
  line-height: 1.25;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hub-item-meta {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hub-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}
.hub-dot.online { background: var(--success); box-shadow: 0 0 8px rgba(0, 255, 136, 0.6); }
.hub-dot.offline { background: var(--danger); }
.hub-dot.probing { background: var(--warning); animation: hub-pulse 1s ease-in-out infinite; }
@keyframes hub-pulse { 50% { opacity: 0.3; } }
.hub-badge {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-muted);
  flex-shrink: 0;
}
.hub-badge.online { color: var(--success); }
.hub-badge.offline { color: var(--danger); }
.hub-hint {
  margin-top: 14px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}
.hub-empty {
  text-align: center;
  padding: 30px 16px;
  color: var(--text-secondary);
}
.messages-new-hint {
  color: var(--text-secondary);
  font-size: 14px;
  text-align: center;
  padding: 40px 20px;
  line-height: 1.5;
}

/* --- Prompts list --- */
.prompts-content { padding: 12px 16px; }
.prompts-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.prompt-button {
  padding: 14px 16px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 15px;
  text-align: left;
  line-height: 1.3;
}
.prompt-button:focus { background: var(--bg-card); }
.prompt-button.sending {
  background: var(--accent-primary);
  color: #0a0a0f;
}

/* Dictate/write input row — a real <input> so the Meta Display opens its
   native text entry (dictation / handwriting) when it's activated. Markup
   and styling deliberately mirror the YouTube viewer's search box, where
   this is proven to work on the glasses. */
.prompt-input-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-shrink: 0;
}
.prompt-input {
  flex: 1;
  min-width: 0;
  padding: 14px 16px;
  font-size: 16px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-radius: var(--radius-md);
}
.prompt-input::placeholder { color: var(--text-muted); }
.prompt-input-send {
  flex: 0 0 auto;
  padding: 0 18px;
  min-width: 64px;
  background: var(--accent-primary);
  color: #0a0a0f;
  font-size: 15px;
  font-weight: 600;
  border-radius: var(--radius-md);
}
.prompt-input-send:focus { background: #33ddff; }
.prompt-input-send.sending { opacity: 0.6; }

/* Same row pinned under the conversation header (main screen). */
.conv-input-row {
  margin-bottom: 0;
  padding: 8px 16px;
  background: var(--bg-secondary);
}

.build-tag {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  padding: 10px 0 4px;
}

/* --- Keyboard screen --- */
.keyboard-text-wrap {
  padding: 8px 12px;
  background: var(--bg-secondary);
  flex-shrink: 0;
}
.keyboard-text {
  width: 100%;
  background: var(--bg-tertiary);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 16px;
  line-height: 1.35;
  color: var(--text-primary);
}
.keyboard-text::placeholder { color: var(--text-muted); }
.keyboard-status {
  padding: 4px 2px 0;
  font-size: 13px;
  font-style: italic;
  color: var(--accent-primary);
}

.keyboard-text-wrap {
  flex: 1;
}
.keyboard-suggestions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px 8px 0;
  flex-shrink: 0;
  min-height: 44px;
}
.suggestion-key {
  background: var(--bg-tertiary);
  color: var(--accent-primary);
  border-radius: 6px;
  font-size: 16px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  height: 40px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.suggestion-key:focus { background: var(--bg-card); }
.suggestion-key.empty { color: var(--text-muted); background: transparent; pointer-events: none; }
.keyboard-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 5px;
  padding: 6px 8px 10px;
  flex-shrink: 0;
}
.kbd-key {
  background: var(--bg-tertiary);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 20px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  min-width: 0;
  user-select: none;
  height: 60px;
}
.kbd-key.focusable { min-height: 0; }
.kbd-key:focus {
  background: var(--bg-card);
}
.kbd-key.wide-2 { grid-column: span 2; }
.kbd-key.wide-3 { grid-column: span 3; }
.kbd-key.wide-4 { grid-column: span 4; }
.kbd-key.wide-5 { grid-column: span 5; }
.kbd-key.wide-6 { grid-column: span 6; }
.kbd-key.wide-7 { grid-column: span 7; }
.kbd-key.wide-8 { grid-column: span 8; }
.kbd-key.kbd-send {
  background: var(--accent-primary);
  color: #0a0a0f;
  font-weight: 600;
}
.kbd-key.kbd-send:focus { background: #33ddff; }
.kbd-key.kbd-action { font-size: 14px; }
.kbd-key.kbd-voice.recording {
  background: var(--danger);
  color: #ffffff;
  animation: kbd-voice-pulse 1.1s ease-in-out infinite;
}
.kbd-key.kbd-voice.transcribing {
  background: var(--accent-warm);
  color: #0a0a0f;
}
@keyframes kbd-voice-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 68, 102, 0.6); }
  50% { box-shadow: 0 0 0 8px rgba(255, 68, 102, 0); }
}
.keyboard-text.listening { border-color: var(--accent-primary); }

/* --- Phone voice mode --- */
#phone {
  padding: 20px 0 0 0;
  padding-top: max(env(safe-area-inset-top, 0px), 20px);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.phone-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: var(--bg-secondary);
  flex-shrink: 0;
}
.phone-target {
  flex: 1;
  font-size: 14px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.phone-header .back-btn { font-size: 24px; padding: 6px 12px; }
.phone-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  gap: 24px;
}
.phone-mic-btn {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: var(--accent-primary);
  color: #0a0a0f;
  border: none;
  font-size: 64px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 24px rgba(0, 212, 255, 0.3);
  transition: transform 0.1s ease, background 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}
.phone-mic-btn:active { transform: scale(0.96); }
.phone-mic-btn.recording {
  background: var(--danger);
  color: #ffffff;
  animation: phone-mic-pulse 1.1s ease-in-out infinite;
}
.phone-mic-btn.transcribing,
.phone-mic-btn.sending {
  background: var(--accent-warm);
  color: #0a0a0f;
}
@keyframes phone-mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 68, 102, 0.45); }
  50% { box-shadow: 0 0 0 24px rgba(255, 68, 102, 0); }
}
.phone-status {
  font-size: 18px;
  color: var(--text-primary);
  text-align: center;
}
.phone-status.error { color: var(--danger); }
.phone-status.success { color: var(--success); }
.phone-last {
  max-width: 480px;
  font-size: 14px;
  color: var(--text-secondary);
  text-align: center;
  font-style: italic;
  word-break: break-word;
  min-height: 1.5em;
}
.phone-input-form {
  display: flex;
  gap: 8px;
  padding: 16px 16px calc(40px + env(safe-area-inset-bottom, 0));
  background: var(--bg-secondary);
  flex-shrink: 0;
}
.phone-input {
  flex: 1;
  padding: 14px 16px;
  font-size: 16px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-radius: var(--radius-md);
  border: 2px solid transparent;
  -webkit-appearance: none;
  appearance: none;
}
.phone-input:focus {
  outline: none;
  border-color: var(--focus-ring);
}
.phone-input::placeholder { color: var(--text-muted); }
.phone-send-btn {
  background: var(--accent-primary);
  color: #0a0a0f;
  font-size: 16px;
  font-weight: 600;
  border: none;
  padding: 0 20px;
  border-radius: var(--radius-md);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.phone-send-btn:active { background: #33ddff; }
.phone-send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* --- Toast --- */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  color: var(--text-primary);
  padding: 12px 24px;
  border-radius: var(--radius-md);
  font-size: 14px;
  border: 1px solid var(--accent-primary);
  z-index: 100;
  pointer-events: none;
  max-width: 540px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0s linear 0.25s;
}
.toast.visible {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.25s ease, visibility 0s linear 0s;
}
.toast.error { border-color: var(--danger); }
.toast.success { border-color: var(--success); }

/* --- Photo upload screen --- */
.photo-content {
  gap: 14px;
  align-items: stretch;
}
.photo-pick-btn {
  padding: 18px 16px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 17px;
  font-weight: 500;
  text-align: center;
  border: 2px dashed var(--accent-secondary);
}
.photo-pick-btn:focus { background: var(--bg-card); }
.photo-replace-btn {
  font-size: 14px;
  padding: 10px 14px;
  border-style: solid;
  border-color: var(--text-muted);
  margin-top: 8px;
}
.photo-preview-wrap {
  display: flex;
  flex-direction: column;
  align-items: stretch;
}
.photo-preview {
  width: 100%;
  max-height: 320px;
  object-fit: contain;
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
}
.photo-caption {
  padding: 12px 14px;
  font-size: 15px;
  font-family: inherit;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  resize: none;
  min-height: 80px;
}
.photo-caption:focus {
  outline: none;
  border-color: var(--focus-ring);
}
body.mobile-mode .photo-preview { max-height: 50vh; }
body.mobile-mode .photo-pick-btn { padding: 22px 18px; font-size: 18px; }
body.mobile-mode .photo-caption { font-size: 16px; min-height: 100px; }

/* --- Permission / approval screen --- */
.header-meta.awaiting { color: var(--accent-warm); animation: perm-pulse 1.5s ease-in-out infinite; }
@keyframes perm-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }
.perm-content {
  gap: 14px;
  justify-content: center;
  align-items: center;
  text-align: center;
}
.perm-tool {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent-warm);
  font-weight: 600;
}
.perm-desc {
  font-size: 18px;
  line-height: 1.35;
  color: var(--text-primary);
  max-width: 500px;
}
.perm-detail {
  font-family: 'Consolas', 'Menlo', monospace;
  font-size: 13px;
  line-height: 1.4;
  color: var(--accent-primary);
  background: var(--bg-tertiary);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  max-width: 100%;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 200px;
  overflow-y: auto;
  text-align: left;
}
.perm-detail:empty { display: none; }
.perm-actions { gap: 8px; }
.perm-deny {
  background: rgba(255, 68, 102, 0.2) !important;
  color: var(--danger) !important;
  flex: 0.8 !important;
}
.perm-deny:focus { background: rgba(255, 68, 102, 0.35) !important; }
.perm-allow { flex: 1.2 !important; }
.perm-always {
  flex: 0.8 !important;
  font-size: 13px !important;
  background: var(--bg-card) !important;
  color: var(--accent-secondary) !important;
}
.perm-always:focus { background: var(--bg-tertiary) !important; }

/* --- Question screen --- */
.question-content {
  gap: 14px;
}
.question-text {
  font-size: 17px;
  line-height: 1.4;
  color: var(--text-primary);
  padding: 8px 0;
}
.question-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.question-option-btn {
  padding: 14px 16px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 15px;
  text-align: left;
  line-height: 1.3;
}
.question-option-btn:focus { background: var(--bg-card); }
.question-option-btn .q-option-label {
  font-weight: 600;
  display: block;
}
.question-option-btn .q-option-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
  display: block;
}

/* --- Mobile mode: full responsive app for phones/tablets --- */
body.mobile-mode {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}
body.mobile-mode #app { width: 100%; height: 100%; }

/* Scale up touch targets and typography for phone screens */
body.mobile-mode .header {
  padding: 34px 16px 14px;
  padding-top: calc(14px + max(env(safe-area-inset-top, 0px), 20px));
  background: var(--bg-tertiary);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
body.mobile-mode .header h1 { font-size: 20px; }
body.mobile-mode .content { padding: 12px 16px; }
body.mobile-mode .nav-bar { padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0)); }
body.mobile-mode .nav-item { padding: 16px 14px; font-size: 16px; min-height: 52px; }

/* Messages: readable on wide/tall phones */
body.mobile-mode .message { font-size: 15px; padding: 12px 14px; }
body.mobile-mode .message.tool { font-size: 13px; }

/* Sessions: bigger tap targets */
body.mobile-mode .session-item { padding: 14px 16px; }
body.mobile-mode .session-item-title { font-size: 16px; }
body.mobile-mode .session-item-meta { font-size: 13px; }

/* Prompts: bigger tap targets */
body.mobile-mode .prompt-button { padding: 16px 18px; font-size: 16px; min-height: 54px; }
/* 16px stops iOS zooming the page when the input gains focus. */
body.mobile-mode .prompt-input { font-size: 16px; min-height: 52px; }
body.mobile-mode .prompt-input-send { min-height: 52px; }

/* Keyboard screen: hide the custom grid & text display, show native form */
body.mobile-mode .keyboard-text-wrap { display: none; }
body.mobile-mode .keyboard-grid { display: none; }
body.mobile-mode .keyboard-suggestions { display: none; }

.mobile-kbd-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  flex: 1;
  min-height: 0;
}
.mobile-kbd-input {
  flex: 1;
  min-height: 120px;
  padding: 14px 16px;
  font-size: 16px;
  font-family: inherit;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  resize: none;
  -webkit-appearance: none;
  appearance: none;
}
.mobile-kbd-input:focus {
  outline: none;
  border-color: var(--focus-ring);
}
.mobile-kbd-input::placeholder { color: var(--text-muted); }
.mobile-kbd-actions {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.mobile-kbd-voice {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: none;
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.mobile-kbd-voice:active { background: var(--bg-card); }
.mobile-kbd-voice.recording {
  background: var(--danger);
  color: #ffffff;
  animation: kbd-voice-pulse 1.1s ease-in-out infinite;
}
.mobile-kbd-voice.transcribing {
  background: var(--accent-warm);
  color: #0a0a0f;
}
.mobile-kbd-send {
  flex: 1;
  height: 52px;
  background: var(--accent-primary);
  color: #0a0a0f;
  font-size: 17px;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.mobile-kbd-send:active { background: #33ddff; }

/* Permission screen: bigger for mobile */
body.mobile-mode .perm-desc { font-size: 18px; }
body.mobile-mode .perm-detail { font-size: 14px; }
body.mobile-mode .perm-actions .nav-item { font-size: 17px; min-height: 56px; }
body.mobile-mode .question-option-btn { padding: 16px 18px; font-size: 16px; min-height: 54px; }

/* Back button: bigger touch target on mobile */
body.mobile-mode .back-btn { font-size: 26px; padding: 8px 14px; min-width: 48px; min-height: 48px; }

/* Toast: position for mobile */
body.mobile-mode .toast { bottom: 100px; max-width: calc(100vw - 40px); }

.prompt-input-hint { display: none; }

/* Meta Display: keep the current neural-band target unmistakable without
   moving controls or changing the phone companion's layout. */
body:not(.mobile-mode):not(.phone-mode) {
  --bg-secondary: #080d13;
  --bg-tertiary: #101b25;
  --bg-card: #162a38;
  --text-secondary: #bdcbd5;
  --text-muted: #8a9eae;
  --focus-ring: #68e6ff;
}

body:not(.mobile-mode):not(.phone-mode) .header {
  padding: 12px 16px;
  gap: 10px;
  min-height: 70px;
  border-bottom: 1px solid #243441;
}
body:not(.mobile-mode):not(.phone-mode) .header h1 {
  font-size: 23px;
  font-weight: 650;
  letter-spacing: -0.3px;
}
body:not(.mobile-mode):not(.phone-mode) .session-subtitle {
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-secondary);
}
body:not(.mobile-mode):not(.phone-mode) .back-btn {
  flex: 0 0 auto;
  min-width: 48px;
  min-height: 46px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
}
body:not(.mobile-mode):not(.phone-mode) .header-refresh {
  min-width: 46px;
  min-height: 46px;
  font-size: 20px;
}

body:not(.mobile-mode):not(.phone-mode) .focusable {
  transition: background-color 100ms ease, border-color 100ms ease;
  scroll-margin-block: 6px;
}
body:not(.mobile-mode):not(.phone-mode) .focusable:focus {
  outline: 2px solid #ffffff;
  outline-offset: 2px;
  border-color: var(--focus-ring);
  box-shadow: inset 0 0 0 1px var(--focus-ring);
}
body:not(.mobile-mode):not(.phone-mode) .focusable:active {
  box-shadow: inset 0 0 0 2px #ffffff;
}
body:not(.mobile-mode):not(.phone-mode) .focusable:disabled {
  opacity: 0.42;
  cursor: default;
}
body:not(.mobile-mode):not(.phone-mode) :is(.hub-item, .session-item, .prompt-button, .question-option-btn) {
  border-width: 2px;
  border-color: #233441;
  min-height: 58px;
}
body:not(.mobile-mode):not(.phone-mode) :is(.hub-item, .session-item).active {
  border-left: 2px solid #3c6478;
  background: #142633;
  box-shadow: inset 4px 0 0 var(--accent-primary);
}
body:not(.mobile-mode):not(.phone-mode) :is(.hub-item, .session-item, .prompt-button, .question-option-btn, .nav-item, .back-btn):focus {
  background: #174052;
}
body:not(.mobile-mode):not(.phone-mode) :is(.hub-item, .session-item):focus {
  box-shadow: inset 4px 0 0 #ffffff;
}
body:not(.mobile-mode):not(.phone-mode) :is(.hub-item-title, .session-item-title) {
  font-size: 17px;
  font-weight: 600;
  line-height: 1.3;
}
body:not(.mobile-mode):not(.phone-mode) :is(.hub-item-meta, .session-item-meta) {
  font-size: 13px;
  line-height: 1.35;
}
body:not(.mobile-mode):not(.phone-mode) .hub-item.unavailable {
  opacity: 1;
  color: var(--text-secondary);
}
body:not(.mobile-mode):not(.phone-mode) .hub-badge {
  font-size: 12px;
}

body:not(.mobile-mode):not(.phone-mode) .nav-bar {
  padding: 12px 16px;
  gap: 10px;
  border-top: 1px solid #243441;
}
body:not(.mobile-mode):not(.phone-mode) .nav-item {
  min-width: 0;
  min-height: 48px;
  padding: 12px 10px;
  font-size: 15px;
  font-weight: 600;
}
body:not(.mobile-mode):not(.phone-mode) :is(.nav-item.primary, .prompt-input-send, .kbd-key.kbd-send):focus {
  background: #c3f6ff;
  color: #03141e;
}
body:not(.mobile-mode):not(.phone-mode) .prompt-input {
  min-height: 52px;
  background: #10212d;
  border-color: #466276;
  font-size: 17px;
}
body:not(.mobile-mode):not(.phone-mode) .prompt-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: 8px;
  row-gap: 6px;
}
body:not(.mobile-mode):not(.phone-mode) .prompt-input:focus {
  background: #173647;
}
body:not(.mobile-mode):not(.phone-mode) .conv-input-row {
  padding: 10px 16px;
}
body:not(.mobile-mode):not(.phone-mode) :is(.navigation-hint, .prompt-input-hint) {
  flex: 0 0 auto;
  padding: 5px 16px 8px;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.4;
  background: var(--bg-secondary);
}
body:not(.mobile-mode):not(.phone-mode) .navigation-hint {
  text-align: center;
}
body:not(.mobile-mode):not(.phone-mode) .prompt-input-hint {
  display: block;
  grid-column: 1 / -1;
  padding: 0;
  background: transparent;
}
body:not(.mobile-mode):not(.phone-mode) .messages-content {
  scrollbar-color: var(--accent-primary) #10212d;
  scrollbar-width: thin;
}
body:not(.mobile-mode):not(.phone-mode) .messages-content:focus {
  outline: 2px solid var(--focus-ring);
  outline-offset: -3px;
  border-color: transparent;
  box-shadow: none;
}
body:not(.mobile-mode):not(.phone-mode) .message {
  padding: 11px 14px;
  font-size: 16px;
  line-height: 1.45;
}
body:not(.mobile-mode):not(.phone-mode) .message-role {
  font-size: 12px;
  font-weight: 700;
}
body:not(.mobile-mode):not(.phone-mode) .message.tool {
  font-size: 13px;
}
body:not(.mobile-mode):not(.phone-mode) .message.system {
  font-size: 13px;
}

@media (prefers-reduced-motion: reduce) {
  body:not(.mobile-mode):not(.phone-mode) .focusable { transition: none; }
}

.hidden { display: none !important; }
