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

:root {
  --bg: #0a0a0a;
  --surface: #141414;
  --surface2: #1e1e1e;
  --text: #e0e0e0;
  --text-dim: #888;
  --accent: #2563eb;
  --jarvis: #1a3a5c;
  --user: #2a2a2a;
  --radius: 12px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

#header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid #222;
  flex-shrink: 0;
}

#header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

#new-chat {
  background: var(--surface2);
  color: var(--text-dim);
  border: 1px solid #333;
  border-radius: 14px;
  padding: 5px 12px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
}

#new-chat:active { transform: scale(0.94); }

#title {
  font-weight: 600;
  font-size: 17px;
}

#status {
  font-size: 12px;
  color: var(--text-dim);
}

#status.thinking { color: var(--accent); }
#status.searching { color: #e8a838; }

#chat {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 12px;
}

#messages {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: var(--radius);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 15px;
}

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

.msg.jarvis {
  align-self: flex-start;
  background: var(--jarvis);
  border-bottom-left-radius: 4px;
}

.msg.jarvis.searched::after {
  content: "🔍";
  font-size: 11px;
  display: block;
  margin-top: 6px;
  opacity: 0.5;
}

.msg.system {
  align-self: center;
  background: transparent;
  color: var(--text-dim);
  font-size: 13px;
  max-width: 90%;
  text-align: center;
}

#input-bar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 12px;
  background: var(--surface);
  border-top: 1px solid #222;
  flex-shrink: 0;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
}

#input {
  flex: 1;
  background: var(--surface2);
  border: 1px solid #333;
  border-radius: 20px;
  color: var(--text);
  padding: 10px 16px;
  font-size: 16px;
  font-family: inherit;
  resize: none;
  max-height: 120px;
  line-height: 1.4;
  outline: none;
}

#input:focus { border-color: var(--accent); }

#send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: white;
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

#send:active { transform: scale(0.92); }
#send:disabled { opacity: 0.4; }

.typing {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-dim);
  animation: blink 1.2s infinite;
}
@keyframes blink { 50% { opacity: 0.2; } }
