:root {
  --page: #f3eee7;
  --screen: #fbfaf8;
  --line: #eee7df;
  --text: #302b28;
  --muted: #a69a91;
  --coral: #e87965;
  --coral-deep: #d85e4d;
  --peach: #f9d8cc;
  --warm-soft: #fff0ea;
  --input-bg: #f8f5f1;
}

* { box-sizing: border-box; }

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

.bg-screen { background: var(--screen); }
.border-line { border-color: var(--line); }
.text-muted { color: var(--muted); }
.text-coral { color: var(--coral); }
.text-coral-deep { color: var(--coral-deep); }
.bg-coral { background: var(--coral); }
.bg-peach { background: var(--peach); }
.accent-coral { accent-color: var(--coral); }

.shadow-phone {
  box-shadow: 0 24px 80px rgba(62, 48, 40, 0.18);
}

.phone {
  height: min(812px, calc(100vh - 2rem));
}

@media (min-width: 1024px) {
  .phone {
    height: min(860px, calc(100vh - 4rem));
  }
}

.scrollbar-hide::-webkit-scrollbar { display: none; }
.scrollbar-hide { scrollbar-width: none; }

.icon-btn {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #796d65;
  text-decoration: none;
  border: none;
  background: transparent;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease;
}

.icon-btn:hover { background: #f7f1eb; }

.quick-chip {
  white-space: nowrap;
  padding: 0.5rem 0.75rem;
  border-radius: 999px;
  background: #f7f1eb;
  color: #756960;
  font-size: 0.75rem;
  border: none;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease;
}

.quick-chip:hover {
  background: var(--warm-soft);
  color: var(--coral-deep);
}

.bubble-tail { position: relative; }
.bubble-tail:after {
  content: "";
  position: absolute;
  bottom: 5px;
  width: 10px;
  height: 10px;
  transform: rotate(45deg);
  background: inherit;
}
.mine:after { right: -4px; }
.theirs:after {
  left: -4px;
  box-shadow: -1px 1px 0 var(--line);
}

.msg-bubble {
  border-radius: 1rem;
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  line-height: 1.6;
  box-shadow: 0 1px 2px rgba(62, 48, 40, 0.04);
  white-space: pre-wrap;
  word-break: break-word;
}

.msg-bubble.mine {
  background: var(--coral);
  color: #fff;
  border-bottom-right-radius: 0.375rem;
}

.msg-bubble.theirs {
  background: #fff;
  border: 1px solid var(--line);
  border-bottom-left-radius: 0.375rem;
  max-width: min(285px, 72vw);
}

.msg-bubble.streaming::after {
  content: "▍";
  margin-left: 2px;
  animation: blink 1s steps(1) infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

.avatar {
  width: 2rem;
  height: 2rem;
  border-radius: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

.copy-btn {
  margin-top: 0.25rem;
  font-size: 11px;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  transition: color 0.18s ease;
}

.copy-btn:hover { color: var(--coral-deep); }

.ref-card {
  padding: 0.75rem;
  border-radius: 1rem;
  background: #fffaf7;
  border: 1px solid #f7dfd5;
  cursor: default;
  transition: background 0.18s ease;
}

.ref-card:hover { background: #fff0ea; }

.ref-empty {
  padding: 0.75rem;
  border-radius: 1rem;
  background: #f8f3ee;
  color: var(--muted);
  font-size: 0.75rem;
}

.energy-card {
  margin-top: 0.5rem;
  border-radius: 1rem;
  background: #fff5ef;
  border: 1px solid #f7dfd5;
  padding: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.style-option {
  width: 100%;
  padding: 1rem;
  border-radius: 1rem;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border: none;
  background: transparent;
  cursor: pointer;
  transition: background 0.18s ease;
}

.style-option:hover { background: #f8f4f0; }
.style-option.active { background: var(--warm-soft); }

#styleModal.flex,
#attachMenu.flex {
  display: flex;
}

#sendBtn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.msg-enter {
  animation: msgIn 0.28s ease;
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .msg-bubble.streaming::after,
  .msg-enter {
    animation: none;
  }
}
