
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #ffffff;
  --surface: #f5f7fb;
  --text: #182033;
  --muted: #737d90;
  --primary: #5367f5;
  --border: #e5e9f2;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--text);
}

button,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.app {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
  background: var(--bg);
}

.topbar {
  min-height: 60px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  background: #fff;
  flex-shrink: 0;
}

.topbar h2 {
  font-size: 20px;
  font-weight: 700;
  flex: 1;
}

.topbar h2::first-letter {
  color: var(--primary);
}

.topbar button {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 10px;
  padding: 9px 12px;
  color: var(--text);
}

.topbar button:active {
  background: var(--surface);
}

#historyPanel {
  position: absolute;
  top: 60px;
  left: 8px;
  width: min(270px, 82vw);
  max-height: 55%;
  overflow-y: auto;
  background: white;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  z-index: 10;
  box-shadow: 0 8px 30px #18203318;
}

#historyPanel h3 {
  font-size: 16px;
  margin-bottom: 12px;
}

#historyList button {
  display: block;
  width: 100%;
  padding: 11px;
  margin-bottom: 7px;
  text-align: left;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 9px;
  overflow-wrap: anywhere;
}

#chatArea {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 20px 14px;
  scroll-behavior: smooth;
}

.welcome {
  width: 100%;
  max-width: 520px;
  margin: 7vh auto 25px;
  text-align: center;
}

.ai-icon {
  width: 62px;
  height: 62px;
  display: grid;
  place-items: center;
  margin: 0 auto 20px;
  border-radius: 22px;
  color: white;
  font-size: 32px;
  background: linear-gradient(135deg, #5367f5, #9867f5);
  box-shadow: 0 8px 24px #5367f530;
}

.welcome h1 {
  font-size: clamp(23px, 6vw, 32px);
  line-height: 1.3;
  margin-bottom: 10px;
}

.welcome p {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.6;
}

.suggestions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 27px;
}

.suggestion {
  min-width: 0;
  min-height: 58px;
  padding: 12px 10px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  color: var(--text);
  text-align: left;
  font-size: 13px;
  line-height: 1.4;
  overflow-wrap: anywhere;
  transition: background 0.2s, border-color 0.2s;
}

.suggestion:hover {
  background: #f4f5ff;
  border-color: #c9ceff;
}

.messages {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.message {
  display: flex;
  flex-direction: column;
  max-width: 90%;
  min-width: 0;
  gap: 5px;
}

.message.user {
  align-self: flex-end;
}

.message.assistant {
  align-self: flex-start;
}

.message-label {
  font-size: 12px;
  color: var(--muted);
}

.message-bubble {
  padding: 12px 15px;
  border-radius: 17px;
  font-size: 15px;
  line-height: 1.65;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.user .message-bubble {
  color: #fff;
  background: var(--primary);
  border-bottom-right-radius: 5px;
}

.assistant .message-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom-left-radius: 5px;
}

.composer-area {
  flex-shrink: 0;
  padding: 10px 12px 8px;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  background: #fff;
  border-top: 1px solid var(--border);
}

.composer {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 7px 7px 7px 14px;
  border: 1px solid #dfe3ed;
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 3px 14px #18203308;
}

.composer:focus-within {
  border-color: #9ba7ff;
  box-shadow: 0 0 0 3px #5367f510;
}

#messageInput {
  width: 100%;
  min-width: 0;
  max-height: 120px;
  resize: none;
  outline: none;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
  padding: 7px 0;
}

#messageInput::placeholder {
  color: #929aaa;
}

#sendBtn {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border: none;
  border-radius: 14px;
  color: #fff;
  background: var(--primary);
  font-size: 25px;
  display: grid;
  place-items: center;
}

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

.disclaimer {
  margin-top: 8px;
  text-align: center;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.4;
}

@media (min-width: 700px) {
  .topbar {
    padding-left: 24px;
    padding-right: 24px;
  }

  #chatArea {
    padding: 28px 24px;
  }

  .composer-area {
    padding-left: 24px;
    padding-right: 24px;
  }
}

@media (max-width: 360px) {
  .topbar {
    gap: 7px;
    padding: 9px;
  }

  .topbar h2 {
    font-size: 18px;
  }

  .suggestions {
    gap: 7px;
  }

  .suggestion {
    padding: 10px 8px;
    font-size: 12px;
  }
}
