:root {
  --lot-red: #b30000;
  --lot-red-dark: #8a0000;
  --lot-red-soft: rgba(179, 0, 0, 0.08);
  --bg: #f4f6fa;
  --surface: #ffffff;
  --text: #1a2233;
  --text-soft: #5a6678;
  --text-muted: #8b94a6;
  --border: #e3e8ef;
  --bubble-user: #b30000;
  --bubble-user-text: #ffffff;
  --bubble-bot: #ffffff;
  --bubble-bot-text: #1a2233;
  --shadow-sm: 0 1px 3px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 6px 20px rgba(16, 24, 40, 0.10);
  --radius: 16px;
  --radius-sm: 10px;
  --maxw: 560px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html,
body {
  height: 100%;
}

body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: var(--maxw);
  margin: 0 auto;
  background: var(--bg);
}

/* Header */
.header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: linear-gradient(135deg, var(--lot-red) 0%, var(--lot-red-dark) 100%);
  color: #fff;
  box-shadow: var(--shadow-md);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
}

.logo-mark {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.15));
}

.header-text {
  flex: 1 1 auto;
  min-width: 0;
}

.header-text h1 {
  font-size: 1.02rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.subtitle {
  font-size: 0.78rem;
  font-weight: 500;
  opacity: 0.85;
  margin-top: 1px;
}

.status-dot {
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.25);
  transition: background 0.3s, box-shadow 0.3s;
}

.status-dot.offline {
  background: #f59e0b;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.25);
}

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

.msg {
  display: flex;
  flex-direction: column;
  max-width: 82%;
  animation: pop 0.22s ease-out;
}

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

.msg .bubble {
  padding: 11px 15px;
  border-radius: var(--radius);
  font-size: 0.95rem;
  line-height: 1.5;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  box-shadow: var(--shadow-sm);
  white-space: pre-wrap;
}

.msg .meta {
  font-size: 0.68rem;
  color: var(--text-muted);
  margin: 4px 6px 0;
}

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

.msg.user .bubble {
  background: var(--bubble-user);
  color: var(--bubble-user-text);
  border-bottom-right-radius: 5px;
}

.msg.bot {
  align-self: flex-start;
  align-items: flex-start;
}

.msg.bot .bubble {
  background: var(--bubble-bot);
  color: var(--bubble-bot-text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 5px;
}

.msg.error .bubble {
  background: #fff4f4;
  color: var(--lot-red-dark);
  border: 1px solid #f5c6c6;
}

/* Typing indicator */
.typing .bubble {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 14px 16px;
}

.typing .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: blink 1.2s infinite ease-in-out;
}

.typing .dot:nth-child(2) {
  animation-delay: 0.2s;
}
.typing .dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes blink {
  0%,
  60%,
  100% {
    opacity: 0.3;
    transform: translateY(0);
  }
  30% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

/* Quick questions */
.quick {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 16px 8px;
}

.quick-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-soft);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  line-height: 1.35;
  padding: 8px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.18s ease;
  box-shadow: var(--shadow-sm);
}

.quick-btn:hover {
  border-color: var(--lot-red);
  color: var(--lot-red);
  background: var(--lot-red-soft);
  transform: translateY(-1px);
}

.quick-btn:active {
  transform: translateY(0);
}

.quick-btn:disabled {
  opacity: 0.5;
  cursor: default;
  transform: none;
}

/* Composer */
.composer {
  display: flex;
  gap: 8px;
  padding: 10px 16px calc(10px + var(--safe-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.input {
  flex: 1 1 auto;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 11px 16px;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--bg);
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
}

.input::placeholder {
  color: var(--text-muted);
}

.input:focus {
  border-color: var(--lot-red);
  box-shadow: 0 0 0 3px var(--lot-red-soft);
}

.send-btn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  border-radius: 999px;
  padding: 11px 18px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, var(--lot-red), var(--lot-red-dark));
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.18s, opacity 0.18s;
  box-shadow: var(--shadow-sm);
}

.send-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.send-btn:active {
  transform: translateY(0);
}

.send-btn:disabled {
  opacity: 0.55;
  cursor: default;
  transform: none;
  box-shadow: none;
}

.send-btn svg {
  display: block;
}

/* Footer */
.footer {
  flex: 0 0 auto;
  padding: 9px 16px calc(9px + var(--safe-bottom));
  background: #1a2233;
  color: #aeb6c4;
  font-size: 0.68rem;
  line-height: 1.45;
  text-align: center;
}

/* Desktop tweaks */
@media (min-width: 600px) {
  .header-inner {
    padding: 16px 20px;
  }
  .header-text h1 {
    font-size: 1.15rem;
  }
  .chat {
    padding: 20px;
  }
  .quick {
    padding: 0 20px 10px;
  }
  .composer {
    padding: 12px 20px calc(12px + var(--safe-bottom));
    gap: 10px;
  }
  .footer {
    padding: 10px 20px calc(10px + var(--safe-bottom));
    font-size: 0.72rem;
  }
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
  .msg,
  .typing .dot,
  .quick-btn,
  .send-btn {
    animation: none !important;
    transition: none !important;
  }
}
