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

:root {
  --bg: #f2eff8;
  --text: #1a1a1a;
  --text-muted: #8c8c8c;
  --text-light: #b0b0b0;
  --accent: #9b7ec4;
  --accent-dim: rgba(155, 126, 196, 0.12);
  --border: #e2dcec;
  --surface: #fff;
  --bubble-user: #4a4458;
  --bubble-bot: #f4f1f8;
  --radius: 20px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-weight: 400;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===== App ===== */
.app {
  width: 100%;
  height: 100vh;
  position: relative;
  display: flex;
  flex-direction: column;
}

/* ===== Chat Area ===== */
.chat-area {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  scroll-behavior: smooth;
}

.chat-area::-webkit-scrollbar { width: 0; }

/* ===== Hero — initially dead center ===== */
.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  max-width: 600px;
  padding: 0 24px 18vh;
  transition: height 0.5s cubic-bezier(0.22, 0.61, 0.36, 1),
              justify-content 0.5s cubic-bezier(0.22, 0.61, 0.36, 1),
              padding 0.5s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.hero.active {
  height: auto;
  justify-content: flex-start;
  padding: 24px 16px 0;
}

/* ===== Ferris Wheel ===== */
.ferris {
  position: relative;
  width: 150px;
  height: 170px;
  margin-bottom: 20px;
  transition: width 0.5s cubic-bezier(0.22, 0.61, 0.36, 1),
              height 0.5s cubic-bezier(0.22, 0.61, 0.36, 1),
              margin 0.5s cubic-bezier(0.22, 0.61, 0.36, 1),
              opacity 0.35s;
}

.hero.active .ferris {
  width: 52px;
  height: 59px;
  margin-bottom: 8px;
  opacity: 0.65;
}

.ferris-stand,
.ferris-wheel {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.ferris-stand { z-index: 2; }

.ferris-wheel {
  z-index: 1;
  animation: wheel-spin 60s linear infinite;
  transform-origin: 50% 44%;  /* wheel center: 110/220=50%, 110/250=44% */
}

@keyframes wheel-spin {
  to { transform: rotate(360deg); }
}

/* ===== Brand ===== */
.brand {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 17px;
  font-weight: 500;
  color: var(--text);
  letter-spacing: 3px;
  margin-bottom: 28px;
  transition: font-size 0.5s cubic-bezier(0.22, 0.61, 0.36, 1),
              letter-spacing 0.5s cubic-bezier(0.22, 0.61, 0.36, 1),
              margin 0.5s cubic-bezier(0.22, 0.61, 0.36, 1),
              opacity 0.35s;
}

.hero.active .brand {
  font-size: 13px;
  letter-spacing: 2px;
  margin-bottom: 12px;
  opacity: 0.65;
}

/* ===== Hero input ===== */
.hero .input-row {
  width: 100%;
}

.hero.active .input-row {
  display: none;
}

/* ===== Input Row (shared) ===== */
.input-row {
  display: flex;
  align-items: center;
  background: var(--surface);
  border-radius: 20px;
  padding: 4px 4px 4px 18px;
  border: 1px solid var(--border);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-row:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.input-row input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 15px;
  color: var(--text);
  padding: 11px 0;
  font-family: inherit;
}

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

.send-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: #d5d0dc;
  color: #fff;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.12s;
}

.send-btn:hover { background: #b8aec8; }
.send-btn:active { transform: scale(0.94); }

.send-btn:disabled {
  background: #e8e4ec;
  cursor: not-allowed;
  transform: none;
}

/* ===== Bottom Input Bar ===== */
.input-bar {
  display: none;
  padding: 10px 24px 22px;
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
}

.input-bar.visible { display: block; }

/* ===== Messages ===== */
.messages {
  width: 100%;
  max-width: 680px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-bottom: 4px;
  margin: 0 auto;
}

.chat-bubble {
  max-width: 82%;
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: 14.5px;
  line-height: 1.7;
  word-break: break-word;
  animation: fadeIn 0.25s ease;
}

.chat-bubble.user {
  align-self: flex-end;
  background: var(--bubble-user);
  color: #fff;
  border-bottom-right-radius: 8px;
}

.chat-bubble.bot {
  align-self: flex-start;
  background: var(--bubble-bot);
  color: var(--text);
  border-bottom-left-radius: 8px;
}

.chat-bubble.error {
  align-self: flex-start;
  background: #fef6f5;
  color: #c44;
  border: 1px solid #fdd;
}

.chat-bubble strong { font-weight: 600; }

.chat-bubble code {
  font-family: inherit;
  background: rgba(0,0,0,0.06);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.92em;
}

/* ===== Typing ===== */
.typing-indicator {
  align-self: flex-start;
  padding: 14px 18px;
  background: var(--bubble-bot);
  border-radius: var(--radius);
  border-bottom-left-radius: 8px;
  display: flex;
  gap: 5px;
}

.typing-indicator span {
  width: 6px;
  height: 6px;
  background: #c4bfb8;
  border-radius: 50%;
  animation: bounce 1.4s ease infinite;
}

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

/* ===== QR Trigger ===== */
.qr-trigger {
  position: fixed;
  bottom: 28px;
  right: 28px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 18px 10px 14px;
  border-radius: 24px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  box-shadow: 0 2px 12px rgba(0,0,0,0.05);
  transition: color 0.15s, border-color 0.15s, box-shadow 0.15s;
  z-index: 10;
}

.qr-trigger:hover {
  color: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}

.qr-trigger svg { flex-shrink: 0; }

/* ===== QR Drawer ===== */
.qr-drawer {
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
}

.qr-drawer.open {
  pointer-events: auto;
  opacity: 1;
}

.qr-drawer-mask {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.3);
  cursor: pointer;
}

.qr-drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 280px;
  background: var(--surface);
  padding: 48px 28px 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  box-shadow: -4px 0 24px rgba(0,0,0,0.08);
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.qr-drawer.open .qr-drawer-panel { transform: translateX(0); }

.qr-drawer-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  transition: color 0.15s;
}

.qr-drawer-close:hover { color: var(--text); }

.qr-drawer-panel h3 {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 1px;
}

.qr-grid {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
}

.qr-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.qr-item img {
  width: 130px;
  height: 130px;
  border-radius: 8px;
  object-fit: contain;
  border: 1px solid var(--border);
}

.qr-item span {
  font-size: 12px;
  color: var(--text-muted);
}

.qr-note {
  font-size: 12px;
  color: var(--text-light);
  text-align: center;
  line-height: 1.6;
}

/* ===== Animations ===== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30%           { transform: translateY(-4px); }
}

/* ===== Responsive ===== */
@media (max-width: 700px) {
  .hero {
    padding: 0 16px;
  }

  .hero.active {
    padding: 20px 12px 0;
  }

  .ferris {
    width: 120px;
    height: 136px;
  }

  .hero.active .ferris {
    width: 44px;
    height: 50px;
  }

  .brand {
    font-size: 16px;
  }

  .hero.active .brand {
    font-size: 12px;
  }

  .chat-bubble {
    max-width: 88%;
    font-size: 14px;
    padding: 10px 14px;
  }

  .input-bar {
    padding: 8px 14px 18px;
  }

  .qr-drawer-panel { width: 100%; }
}
