:root {
  --bg: #0e0f12;
  --bg-soft: #17181d;
  --bubble-user: #2a2d36;
  --bubble-ai: #1d1f26;
  --border: #2c2f38;
  --text: #f2f0ea;
  --text-dim: #a8a49a;
  --accent: #ffb020;
  --accent-soft: rgba(255, 176, 32, 0.15);
  --green: #37d07d;
  --danger: #ff5a5a;
  --radius: 18px;
  --max-w: 480px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  height: 100%;
}

body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  background: radial-gradient(1200px 600px at 50% -10%, #1c1e26 0%, var(--bg) 55%);
  color: var(--text);
  display: flex;
  justify-content: center;
}

.app {
  width: 100%;
  max-width: var(--max-w);
  height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ---------- Header ---------- */
.topbar {
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
  background: rgba(14, 15, 18, 0.85);
  backdrop-filter: blur(8px);
  z-index: 5;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  font-size: 30px;
}

.brand-text h1 {
  font-size: 19px;
  letter-spacing: 0.5px;
}

.brand-text p {
  font-size: 12px;
  color: var(--text-dim);
}

/* ---------- Modos ---------- */
.modes {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px 16px;
  scrollbar-width: none;
  background: rgba(14, 15, 18, 0.85);
  backdrop-filter: blur(8px);
  z-index: 5;
}

.modes::-webkit-scrollbar {
  display: none;
}

.mode-chip {
  flex: 0 0 auto;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text-dim);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.mode-chip[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #17140c;
  font-weight: 700;
}

/* ---------- Chat ---------- */
.chat {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.bubble {
  display: flex;
  flex-direction: column;
  max-width: 88%;
  animation: pop 0.2s ease;
}

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

.bubble.user {
  align-self: flex-end;
}

.bubble .row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.bubble.user .row {
  flex-direction: row-reverse;
}

.avatar {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  border-radius: 50%;
  background: var(--accent-soft);
  display: grid;
  place-items: center;
  font-size: 16px;
}

.msg {
  background: var(--bubble-ai);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  border-top-left-radius: 4px;
  padding: 11px 14px;
  font-size: 14.5px;
  line-height: 1.5;
  white-space: normal;
  word-break: break-word;
}

.msg p {
  margin: 0 0 14px;
  line-height: 1.65;
}

.msg p:last-child {
  margin-bottom: 0;
}

.menu-list {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.menu-card {
  border: 1px solid rgba(255, 176, 32, 0.22);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.035);
  padding: 9px 10px;
}

.menu-card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.menu-card-name {
  color: var(--text);
  font-weight: 700;
}

.menu-card-price {
  color: var(--accent);
  font-weight: 800;
  white-space: nowrap;
}

.menu-card-description {
  display: block;
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.4;
  margin-top: 3px;
}

.menu-line {
  display: block;
  margin-top: 5px;
}

.bubble.user .msg {
  background: var(--bubble-user);
  border-radius: var(--radius);
  border-top-right-radius: 4px;
}

.notice {
  background: rgba(255, 90, 90, 0.12);
  border: 1px solid var(--danger);
  color: #ffb4b4;
  font-size: 12.5px;
  line-height: 1.4;
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 4px;
}

.notice strong {
  color: #fff;
}

.msg strong {
  color: var(--accent);
}

.msg em {
  color: var(--text-dim);
}

.msg-actions {
  display: flex;
  gap: 8px;
  margin-top: 6px;
  margin-left: 42px;
}

.listen-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text-dim);
  font-size: 12.5px;
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.listen-btn:hover {
  color: var(--text);
}

.listen-btn.speaking {
  color: #17140c;
  background: var(--accent);
  border-color: var(--accent);
}

.cursor::after {
  content: "▌";
  color: var(--accent);
  animation: blink 0.8s steps(2) infinite;
}

@keyframes blink {
  to {
    opacity: 0;
  }
}

/* ---------- Chips ---------- */
.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 16px 12px;
  scrollbar-width: none;
}

.chips::-webkit-scrollbar {
  display: none;
}

.chip {
  flex: 0 0 auto;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text-dim);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.chip:active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}

/* ---------- Composer ---------- */
.composer {
  border-top: 1px solid var(--border);
  padding: 10px 16px calc(12px + env(safe-area-inset-bottom));
  background: rgba(14, 15, 18, 0.9);
  backdrop-filter: blur(8px);
}

.input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

#text-input {
  flex: 1;
  min-width: 0;
  background: var(--bubble-user);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 12px 16px;
  font-size: 15px;
  outline: none;
  transition: border 0.15s ease;
}

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

.icon-btn {
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: grid;
  place-items: center;
  color: #17140c;
  transition: transform 0.1s ease;
}

.icon-btn:active {
  transform: scale(0.92);
}

.send-btn {
  background: var(--accent);
}

.mic-btn {
  background: var(--bubble-user);
  border: 1px solid var(--border);
  color: var(--text-dim);
}

.mic-btn.recording {
  background: var(--danger);
  color: #fff;
  animation: throb 1s ease infinite;
}

@keyframes throb {
  50% {
    transform: scale(1.08);
  }
}

.hint {
  margin-top: 8px;
  text-align: center;
  font-size: 11.5px;
  color: var(--text-dim);
}

/* ---------- Recording bar ---------- */
.recording-bar {
  position: absolute;
  left: 50%;
  bottom: 110px;
  transform: translateX(-50%);
  background: var(--danger);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  border-radius: 999px;
  padding: 10px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 20;
  white-space: nowrap;
}

.recording-bar[hidden] {
  display: none;
}

.pulse-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #fff;
  animation: pulse 0.9s ease infinite;
}

@keyframes pulse {
  50% {
    transform: scale(1.5);
    opacity: 0.5;
  }
}

/* ---------- Toast ---------- */
.toast {
  position: absolute;
  left: 50%;
  bottom: 90px;
  transform: translateX(-50%) translateY(10px);
  background: #3a2317;
  border: 1px solid var(--accent);
  color: var(--accent);
  font-size: 13px;
  border-radius: 12px;
  padding: 10px 14px;
  max-width: 90%;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
  z-index: 30;
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
