@import url("/theme/tokens/tokens.css");

*,
*::before,
*::after { box-sizing: border-box; }

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

.chat-wrap {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: max(12px, env(safe-area-inset-top, 0)) max(12px, env(safe-area-inset-right, 0)) max(12px, env(safe-area-inset-bottom, 0)) max(12px, env(safe-area-inset-left, 0));
  background:
    linear-gradient(160deg, color-mix(in srgb, var(--accent) 15%, transparent), transparent 45%),
    var(--bg);
}
.chat-box {
  width: min(440px, 100%);
  height: min(720px, calc(100dvh - 24px));
  max-height: calc(100vh - 24px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.chat-box header {
  padding: 14px 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  font-weight: 800;
}
.chat-msgs {
  flex: 1;
  overflow: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  -webkit-overflow-scrolling: touch;
}
.chat-msgs .bubble {
  max-width: 85%;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  word-break: break-word;
}
.chat-msgs .bubble.me {
  align-self: flex-end;
  background: color-mix(in srgb, var(--accent) 20%, var(--surface));
}
.chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 12px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0));
  border-top: 1px solid var(--border);
}
.chat-form[hidden] { display: none !important; }
.chat-status {
  margin: 0;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
}
.chat-status[hidden] { display: none !important; }
.chat-form input, .chat-form button {
  padding: 10px 12px;
  min-height: 44px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font: inherit;
}
.chat-form button {
  background: var(--accent);
  color: var(--accent-contrast);
  border: 0;
  font-weight: 700;
  cursor: pointer;
}

@media (max-width: 560px) {
  .chat-wrap { padding: 0; }
  .chat-box {
    width: 100%;
    height: 100dvh;
    max-height: none;
    border-radius: 0;
    border: 0;
  }
  .chat-form {
    grid-template-columns: 1fr;
  }
  .chat-form button { width: 100%; }
}
