:root {
  --panel: #fffdf8;
  --panel-alt: #f1f7f3;
  --border: #d8d3c7;
  --text: #23313b;
  --muted: #61707d;
  --accent: #1f6b57;
  --danger: #9f3c2f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  font-family: Georgia, "Times New Roman", serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.9), transparent 30%),
    linear-gradient(180deg, #f7efe3 0%, #dde9e1 100%);
}

.page {
  display: flex;
  flex-direction: column;
  width: min(900px, calc(100% - 32px));
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  padding: 24px 0;
}

.chat-shell {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  background: rgba(255, 253, 248, 0.84);
  border: 1px solid var(--border);
  border-radius: 24px;
  overflow: hidden;
  min-height: 0;
  height: 100%;
  box-shadow: 0 18px 44px rgba(38, 50, 56, 0.12);
  backdrop-filter: blur(8px);
}

.chat-toolbar {
  display: flex;
  flex-shrink: 0;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 16px 20px 15px;
  border-bottom: 1px solid var(--border);
  background:
    linear-gradient(180deg, rgba(255, 253, 248, 0.98), rgba(248, 244, 235, 0.94));
  box-shadow: 0 6px 18px rgba(38, 50, 56, 0.05);
  backdrop-filter: blur(10px);
}

.chat-toolbar > div {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#new-session {
  margin-left: auto;
  flex-shrink: 0;
  margin-top: 2px;
  padding: 12px 20px;
}

.toolbar-title {
  margin: 0;
  font-weight: 700;
  font-size: clamp(1.8rem, 2.4vw, 2.3rem);
  line-height: 1.02;
}

.toolbar-copy {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.35;
  max-width: 34ch;
}

.messages {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  padding: 20px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-padding-bottom: 24px;
}

.starter-prompts {
  padding: 0 20px 16px;
}

.starter-prompts[hidden] {
  display: none;
}

.starter-prompts-label {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.starter-prompts-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.starter-prompt-button {
  padding: 10px 14px;
  border: 1px solid rgba(31, 107, 87, 0.18);
  background: rgba(241, 247, 243, 0.95);
  color: var(--text);
  font-size: 0.94rem;
  line-height: 1.3;
  text-align: left;
}

.starter-prompt-button:hover,
.starter-prompt-button:focus-visible {
  background: #e7f2ec;
  border-color: rgba(31, 107, 87, 0.32);
}

.message {
  max-width: 84%;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--panel);
}

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

.message.assistant {
  align-self: flex-start;
  background: var(--panel-alt);
}

.role {
  margin: 0 0 8px;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.content {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.55;
}

.typing-content {
  display: flex;
  align-items: center;
  min-height: 28px;
}

.typing-shell {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.typing-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: rgba(35, 49, 59, 0.35);
  animation: typing-bounce 1s infinite ease-in-out;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.14s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.28s;
}

.sources {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(35, 49, 59, 0.12);
}

.sources-label {
  margin: 0 0 8px;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.sources-list {
  margin: 0;
  padding-left: 18px;
}

.sources-list li + li {
  margin-top: 6px;
}

.sources-list a {
  color: var(--accent);
}

.composer {
  margin-top: auto;
  padding: 18px 20px 20px;
  border-top: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.5);
}

.composer-field {
  position: relative;
}

.composer textarea {
  width: 100%;
  resize: none;
  min-height: 90px;
  padding: 18px 112px 18px 14px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: #fff;
  font: inherit;
  color: var(--text);
}

.composer-field button {
  position: absolute;
  top: 14px;
  right: 14px;
}

.status {
  color: var(--muted);
  font-size: 0.95rem;
}

.status.is-success {
  color: var(--accent);
}

.status.is-error {
  color: var(--danger);
}

button {
  padding: 11px 18px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: white;
  font: inherit;
  cursor: pointer;
}

.secondary-button {
  background: linear-gradient(180deg, rgba(225, 235, 228, 0.98), rgba(214, 228, 220, 0.95));
  border: 1px solid rgba(31, 107, 87, 0.12);
  color: var(--accent);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

button:disabled {
  opacity: 0.65;
  cursor: wait;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@keyframes typing-bounce {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.35;
  }

  40% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

@media (max-width: 680px) {
  .page {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    padding: 0;
  }

  .chat-shell {
    height: 100%;
    border-right: 0;
    border-left: 0;
    border-radius: 0;
  }

  .messages {
    padding: 16px;
    scroll-padding-bottom: 120px;
  }

  .starter-prompts {
    padding: 0 16px 14px;
  }

  .starter-prompts-list {
    gap: 8px;
  }

  .starter-prompt-button {
    width: 100%;
    padding: 11px 13px;
    font-size: 0.91rem;
  }

  .chat-toolbar {
    gap: 12px;
    padding: 12px 16px;
  }

  .chat-toolbar > div {
    gap: 2px;
  }

  .toolbar-copy {
    display: none;
  }

  .toolbar-title {
    font-size: 1.18rem;
    line-height: 1.08;
  }

  #new-session {
    margin-top: 0;
    padding: 9px 14px;
    font-size: 0.88rem;
  }

  .composer {
    position: sticky;
    bottom: 0;
    z-index: 1;
    padding: 14px 16px 16px;
    background: rgba(255, 253, 248, 0.96);
    box-shadow: 0 -10px 24px rgba(38, 50, 56, 0.08);
    backdrop-filter: blur(8px);
  }

  .composer textarea {
    min-height: 72px;
    padding: 18px 96px 18px 14px;
  }

  .composer-field button {
    top: 12px;
    right: 12px;
  }

  .message {
    max-width: 100%;
  }
}
