@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg: #0B0E14;
  --surface: #131720;
  --surface-2: #1A2029;
  --border: #232A36;
  --text: #E8EAED;
  --text-dim: #8B93A1;
  --accent: #FFB454;
  --accent-dim: #8A6A3A;
  --danger: #FF6B6B;

  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

.app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(ellipse 900px 500px at 50% -10%, rgba(255,180,84,0.06), transparent),
    var(--bg);
}

/* ---- Status bar ---- */
.statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 18px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.statusbar-left {
  display: flex;
  align-items: center;
  gap: 9px;
}

.wordmark {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.12em;
  font-size: 14px;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: background 0.3s ease, box-shadow 0.3s ease;
}
.dot.online {
  background: var(--accent);
  box-shadow: 0 0 8px 1px rgba(255,180,84,0.6);
}
.dot.error {
  background: var(--danger);
  box-shadow: 0 0 8px 1px rgba(255,107,107,0.5);
}

.statusbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.statusbar-right #statusText {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}

.mute-btn {
  width: 24px;
  height: 24px;
  border: none;
  background: none;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}
.mute-btn:active { transform: scale(0.9); }
.mute-btn.muted {
  color: var(--danger);
}
.mute-btn.muted #wavePath {
  display: none;
}

/* ---- Thread ---- */
.thread {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.empty-state {
  margin: auto;
  text-align: center;
  color: var(--text-dim);
}
.empty-glyph {
  font-size: 28px;
  color: var(--accent-dim);
  margin-bottom: 10px;
}
.empty-title {
  font-family: var(--font-display);
  font-size: 15px;
  color: var(--text);
  margin-bottom: 4px;
}
.empty-sub {
  font-size: 13px;
}

.msg {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 15px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-wrap: break-word;
  animation: rise 0.22s ease;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg.user {
  align-self: flex-end;
  background: var(--accent);
  color: #1A1200;
  border-bottom-right-radius: 4px;
}

.msg.jarvis {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.replay-btn {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border: none;
  background: none;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  opacity: 0.7;
}
.replay-btn:active {
  color: var(--accent);
  transform: scale(0.9);
}

.search-tag {
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--accent-dim);
}

.msg.thinking {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 12px 16px;
}
.msg.thinking span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-dim);
  animation: pulse 1.2s ease-in-out infinite;
}
.msg.thinking span:nth-child(2) { animation-delay: 0.15s; }
.msg.thinking span:nth-child(3) { animation-delay: 0.3s; }

@keyframes pulse {
  0%, 60%, 100% { opacity: 0.3; transform: scale(0.85); }
  30% { opacity: 1; transform: scale(1); }
}

.msg.error {
  align-self: flex-start;
  background: rgba(255,107,107,0.08);
  border: 1px solid rgba(255,107,107,0.3);
  color: var(--danger);
  border-bottom-left-radius: 4px;
}

/* ---- Composer ---- */
.composer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px calc(env(safe-area-inset-bottom, 0px) + 12px);
  border-top: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}

.mic-btn, .send-btn {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.mic-btn:active, .send-btn:active { transform: scale(0.94); }

.mic-btn.listening {
  color: var(--accent);
  border-color: var(--accent-dim);
  background: rgba(255,180,84,0.08);
  animation: mic-pulse 1.4s ease-in-out infinite;
}
@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,180,84,0.35); }
  50% { box-shadow: 0 0 0 7px rgba(255,180,84,0); }
}

.send-btn {
  background: var(--accent);
  color: #1A1200;
  border-color: var(--accent);
}
.send-btn:disabled {
  background: var(--surface-2);
  color: var(--text-dim);
  border-color: var(--border);
  cursor: default;
}

.text-input {
  flex: 1;
  min-width: 0;
  height: 38px;
  padding: 0 14px;
  border-radius: 19px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  outline: none;
}
.text-input:focus {
  border-color: var(--accent-dim);
}
.text-input::placeholder {
  color: var(--text-dim);
}

/* Visible keyboard focus for accessibility */
button:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .msg, .mic-btn.listening, .msg.thinking span {
    animation: none !important;
  }
}

/* ---- Lock screen ---- */
.lock-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background:
    radial-gradient(ellipse 900px 500px at 50% -10%, rgba(255,180,84,0.06), transparent),
    var(--bg);
}
.lock-overlay.visible {
  display: flex;
}

.lock-box {
  width: 100%;
  max-width: 300px;
  text-align: center;
}

.lock-glyph {
  font-size: 28px;
  color: var(--accent-dim);
  margin-bottom: 10px;
}

.lock-title {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.12em;
  font-size: 16px;
  margin-bottom: 6px;
}

.lock-sub {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 20px;
}

.lock-input {
  width: 100%;
  height: 42px;
  padding: 0 14px;
  margin-bottom: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 15px;
  text-align: center;
  letter-spacing: 0.06em;
  outline: none;
}
.lock-input:focus {
  border-color: var(--accent-dim);
}
.lock-input::placeholder {
  color: var(--text-dim);
  letter-spacing: normal;
}

.lock-submit {
  width: 100%;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #1A1200;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
}
.lock-submit:active {
  transform: scale(0.98);
}

.lock-error {
  margin-top: 14px;
  min-height: 16px;
  font-size: 12.5px;
  color: var(--danger);
}