@font-face {
  font-family: "Yozai Medium";
  src: url("/static/Yozai-Medium-3aee01c0.woff2") format("woff2");
  font-style: normal;
  font-weight: 500;
  font-display: swap;
}

:root {
  --bg: #fdfbf9;
  --surface: #ffffff;
  --border-soft: #e5dfda;
  --ink: #4a4138;
  --muted: #a39c95;
  --mine: #fceaeb;
  --his: #f2efeb;
  --accent: #e8c5c8;
  --accent-hover: #dfb5b9;
  --good: #5e8c61;
  --bad: #b55b52;
  --font-chat: "Yozai Medium", "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", -apple-system, BlinkMacSystemFont, sans-serif;
}

* { box-sizing: border-box; }

html,
body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-chat);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.5;
}

body { display: flex; justify-content: center; }

.room {
  width: min(100%, 760px);
  height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: var(--bg);
}

header {
  min-height: 44px;
  padding: max(6px, env(safe-area-inset-top)) 16px 6px;
  border-bottom: 0;
  background: var(--bg);
}

h1 { font-size: 16px; line-height: 1.2; margin: 0; color: var(--ink); }

.status {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.online { color: var(--good); }
.offline { color: var(--bad); }

#messages {
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow: auto;
  padding: 16px max(16px, env(safe-area-inset-right)) 26px max(16px, env(safe-area-inset-left));
  scroll-behavior: smooth;
}

.row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
  margin: 0;
}

.row + .row { margin-top: 16px; }
.row.same-role { margin-top: 4px; }

.row.user { justify-content: flex-end; }
.row.assistant { justify-content: flex-start; }

.bubble {
  width: fit-content;
  max-width: 72%;
  max-inline-size: 72%;
  min-width: 0;
  flex: 0 1 auto;
  padding: 10px 14px;
  border: none;
  border-radius: 18px;
  box-shadow: none;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  background: var(--his);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
}

.assistant .bubble {
  color: var(--ink);
  background: var(--his);
}

.user .bubble {
  color: var(--ink);
  background: var(--mine);
}

.chat-avatar {
  width: 36px;
  height: 36px;
  min-width: 36px;
  flex: 0 0 36px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 0;
  border-radius: 50%;
  background: var(--his);
  color: var(--ink);
  object-fit: cover;
  font-size: 13px;
  line-height: 1;
  animation: none !important;
  transition: none !important;
  transform: none !important;
}

.avatar-fallback { font-size: 12px; }
.avatar-spacer { visibility: hidden; }

.time { margin-top: 4px; color: var(--muted); font-size: 11px; line-height: 1.2; }

.composer {
  padding: 10px 10px max(10px, env(safe-area-inset-bottom));
  background: var(--bg);
  border-top: 0;
}

.model-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
}

select {
  min-width: 0;
  max-width: 65%;
  padding: 5px;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  font-family: var(--font-chat);
  font-size: inherit;
  font-weight: 500;
}

form { display: flex; gap: 8px; }

textarea {
  flex: 1;
  min-height: 44px;
  max-height: 120px;
  resize: none;
  padding: 10px 12px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 20px;
  font-family: var(--font-chat);
  font-size: inherit;
  font-weight: 500;
}

textarea:focus,
select:focus,
.auth-card input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

button {
  padding: 0 16px;
  color: #ffffff;
  background: var(--accent);
  border: none;
  border-radius: 20px;
  font-family: var(--font-chat);
  font-size: inherit;
  font-weight: 500;
}

button:active { background: var(--accent-hover); }
button:disabled { opacity: 0.5; }

.error {
  margin-top: 6px;
  color: var(--bad);
  font-size: 12px;
  white-space: pre-wrap;
}

.auth {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(255, 249, 245, 0.96);
}

.auth-card {
  display: block;
  width: min(100%, 390px);
  padding: 22px;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 18px;
  box-shadow: none;
}

.auth-card input {
  width: 100%;
  margin: 14px 0;
  padding: 12px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 20px;
  font-family: var(--font-chat);
  font-size: inherit;
  font-weight: 500;
}

.auth-button { width: 100%; height: 44px; }
.hidden { display: none !important; }

.bubble,
label,
input,
textarea,
button,
select {
  font-family: var(--font-chat);
}

pre,
code,
.diagnostics {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}
