:root {
  --bg: #f4f1ea;
  --panel: #ffffff;
  --ink: #2b2620;
  --ink-soft: #6f675d;
  --line: #e3ddd1;
  --brand: #8a6a3b;
  --brand-deep: #5f4826;
  --assistant: #ffffff;
  --user: #2f5d50;
  --user-ink: #f3faf7;
  --clarify: #fff8ec;
  --reject: #fbecec;
  --reject-line: #c0564f;
  --radius: 16px;
  --shadow: 0 6px 22px rgba(60, 48, 30, 0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "PingFang HK", "Microsoft JhengHei", "Noto Sans TC", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px calc(12px + env(safe-area-inset-top));
  padding-top: calc(14px + env(safe-area-inset-top));
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, var(--brand), var(--brand-deep));
  color: #fff8ec; font-size: 20px; font-weight: 700;
}
.topbar h1 { font-size: 17px; margin: 0; letter-spacing: 1px; }
.subtitle { margin: 2px 0 0; font-size: 12px; color: var(--ink-soft); }

.top-actions { display: flex; gap: 8px; }
.ghost-btn {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
}
.ghost-btn:active { transform: scale(0.97); }

.chat {
  flex: 1;
  overflow-y: auto;
  padding: 18px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.bubble { display: flex; }
.bubble.user { justify-content: flex-end; }
.bubble-inner {
  max-width: 84%;
  padding: 12px 14px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: 15px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}
.bubble.assistant .bubble-inner { background: var(--assistant); border: 1px solid var(--line); border-top-left-radius: 4px; }
.bubble.user .bubble-inner { background: var(--user); color: var(--user-ink); border-top-right-radius: 4px; }
.bubble.clarify .bubble-inner { background: var(--clarify); border: 1px solid #e9d8b4; }
.bubble.reject .bubble-inner { background: var(--reject); border: 1px solid var(--reject-line); color: #7a3530; }

.bubble .kind-tag {
  display: inline-block;
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--brand-deep);
  background: #f1e7d3;
  border-radius: 999px;
  padding: 2px 8px;
  margin-bottom: 6px;
}
.bubble.reject .kind-tag { color: #7a3530; background: #f3d9d7; }
.example { color: var(--brand-deep); font-weight: 600; }

.composer {
  padding: 10px 12px calc(12px + env(safe-area-inset-bottom));
  background: var(--panel);
  border-top: 1px solid var(--line);
}
.composer form { display: flex; gap: 8px; align-items: flex-end; }
#input {
  flex: 1;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 11px 14px;
  font: inherit;
  font-size: 15px;
  max-height: 120px;
  background: #fbf9f4;
  color: var(--ink);
}
#input:focus { outline: 2px solid rgba(138, 106, 59, 0.35); }
#send-btn {
  width: 44px; height: 44px;
  border: none; border-radius: 14px;
  background: var(--user); color: var(--user-ink);
  display: grid; place-items: center;
  cursor: pointer;
}
#send-btn:disabled { opacity: 0.45; cursor: default; }
.footnote { margin: 8px 4px 0; font-size: 11px; color: var(--ink-soft); text-align: center; }

.typing { display: inline-flex; gap: 4px; padding: 4px 2px; }
.typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--ink-soft);
  animation: blink 1.2s infinite ease-in-out;
}
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }
