:root {
  --bg: #ffffff;
  --text: #000000;
  --muted: #6a6a6a;
  --border: #e5e5e5;
  --pill: #d8d8d8;
  --pill-hover: #c8c8c8;
  --bubble-user: #f4f4f4;
  --bubble-assistant: #ffffff;
  --font: "Space Grotesk", "Noto Sans Thai", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.page {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 5;
  padding: 1.1rem 1.25rem;
}

.lang-switch {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.08em;
}

.lang-sep {
  color: var(--text);
  opacity: 0.45;
  user-select: none;
}

.lang-btn {
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: inherit;
  font-weight: 500;
  letter-spacing: inherit;
  cursor: pointer;
  line-height: 1;
}

.lang-btn:hover { color: var(--text); }
.lang-btn.is-active { color: var(--text); }

.landing {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 3.25rem 1.25rem 1.75rem;
  text-align: center;
  min-height: 100vh;
  min-height: 100dvh;
}

.brand {
  margin-top: 0.35rem;
  flex-shrink: 0;
}

.brand-logo {
  display: block;
  width: min(180px, 48vw);
  height: auto;
  margin: 0 auto;
  object-fit: contain;
}

.brand-name {
  margin: 0.55rem 0 0;
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 0.42em;
  text-indent: 0.42em;
  text-transform: uppercase;
}

.landing-copy {
  margin-top: 1.75rem;
  flex-shrink: 0;
}

.landing-title {
  margin: 0;
  font-size: clamp(0.9rem, 3.2vw, 1.1rem);
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.landing-sub {
  margin: 0.7rem 0 0;
  font-size: clamp(0.75rem, 2.6vw, 0.88rem);
  font-weight: 400;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text);
}

.chat-dock {
  width: 100%;
  max-width: 420px;
  margin-top: auto;
  padding-top: 1.5rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1 1 auto;
  justify-content: flex-end;
}

.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  overflow-y: auto;
  text-align: left;
  padding: 0.25rem 0.15rem 0.85rem;
  max-height: min(42vh, 360px);
  min-height: 0;
}

.chat-messages.is-empty {
  display: none;
}

.chat-bubble {
  max-width: 92%;
  padding: 0.6rem 0.8rem;
  font-size: 0.9rem;
  line-height: 1.5;
  word-break: break-word;
}

.chat-bubble.user {
  align-self: flex-end;
  background: var(--bubble-user);
  border: 1px solid var(--border);
}

.chat-bubble.assistant {
  align-self: flex-start;
  background: var(--bubble-assistant);
  border: 1px solid var(--text);
}

.attachment-tag {
  font-size: 0.75rem;
  color: var(--muted);
}

.chat-composer {
  margin: 0;
  width: 100%;
}

.composer-inline {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
}

.attach-btn {
  flex: 0 0 auto;
  width: 2rem;
  height: 2rem;
  margin: 0;
  padding: 0;
  border: 1px solid var(--text);
  border-radius: 0;
  background: var(--bg);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  line-height: 0;
}

.attach-btn:hover {
  background: var(--text);
  color: var(--bg);
}

.attach-btn:disabled {
  opacity: 0.4;
  cursor: wait;
}

.chat-box {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--pill);
  border-radius: 999px;
  padding: 0.35rem 0.45rem 0.35rem 1rem;
  transition: background 0.15s ease;
}

.chat-box:focus-within {
  background: var(--pill-hover);
}

.chat-box textarea {
  flex: 1;
  min-width: 0;
  resize: none;
  border: 0;
  outline: none;
  background: transparent;
  padding: 0.55rem 0;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  line-height: 1.3;
  min-height: 1.35rem;
  max-height: 5.5rem;
  color: var(--text);
}

.chat-box textarea::placeholder {
  color: var(--text);
  opacity: 0.85;
  letter-spacing: 0.14em;
}

.chat-box textarea:not(:placeholder-shown) {
  text-transform: none;
  letter-spacing: 0.01em;
  font-size: 0.88rem;
  font-weight: 400;
}

.send-btn {
  flex: 0 0 auto;
  width: 2.1rem;
  height: 2.1rem;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--text);
  color: var(--bg);
  font: inherit;
  font-size: 0.75rem;
  cursor: pointer;
  line-height: 1;
}

.send-btn:hover {
  opacity: 0.88;
}

.send-btn:disabled {
  opacity: 0.35;
  cursor: wait;
}

.status {
  min-height: 0;
  font-size: 0.78rem;
  margin: 0.45rem 0 0;
  padding: 0 0.35rem;
  color: var(--muted);
  text-align: left;
}

.status:empty { display: none; }
.status.ok { color: var(--text); font-weight: 500; }
.status.err { color: var(--text); text-decoration: underline; }

.hp { position: absolute; left: -9999px; opacity: 0; height: 0; width: 0; }

@media (max-width: 520px) {
  .landing {
    padding: 3rem 1rem 1.35rem;
  }

  .chat-dock {
    max-width: 100%;
  }

  .brand-logo {
    width: min(160px, 52vw);
  }
}
