:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --panel-soft: #334155;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --user: #0284c7;
  --danger: #f87171;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
  gap: 12px;
}

.app-header h1 {
  margin: 0;
  font-size: 1.25rem;
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--panel-soft);
  padding: 4px 10px;
  font-size: 0.85rem;
  border-radius: 6px;
  cursor: pointer;
}
.btn-ghost:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--accent);
}
.btn-ghost:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.status {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
  min-height: 1.2em;
}

.messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 4px;
}

.msg {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 85%;
}

.msg-user { align-self: flex-end; align-items: flex-end; }
.msg-assistant { align-self: flex-start; align-items: flex-start; }

.bubble {
  margin: 0;
  padding: 10px 14px;
  border-radius: 14px;
  background: var(--panel);
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg-user .bubble { background: var(--user); }

audio { width: 240px; max-width: 100%; }

.composer {
  display: flex;
  gap: 8px;
}

.text-input {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--panel-soft);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  font-size: 1rem;
}

.text-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.btn {
  border: none;
  border-radius: 12px;
  padding: 0 16px;
  font-size: 1rem;
  color: #0f172a;
  background: var(--accent);
  cursor: pointer;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-record {
  background: var(--panel-soft);
  color: var(--text);
  font-size: 1.15rem;
}

.btn-record.recording {
  background: var(--danger);
  color: #1f2937;
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  50% { opacity: 0.6; }
}

@media (max-width: 480px) {
  .app { padding: 12px; }
  .msg { max-width: 92%; }
}
