:root {
  color-scheme: light;
  --ink: #151515;
  --muted: #646464;
  --paper: #fbfaf7;
  --line: #ded9cf;
  --panel: #ffffff;
  --accent: #1f766d;
  --accent-dark: #14524c;
  --warn: #8a3d15;
  --shadow: 0 18px 60px rgba(21, 21, 21, 0.11);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(31, 118, 109, 0.08) 1px, transparent 1px),
    linear-gradient(rgba(138, 61, 21, 0.06) 1px, transparent 1px),
    var(--paper);
  background-size: 36px 36px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
textarea {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  place-items: stretch center;
  padding: 28px;
}

.chat-pane {
  width: min(920px, 100%);
  min-height: calc(100vh - 56px);
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.topbar {
  min-height: 92px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(251, 250, 247, 0.82);
}

h1,
p,
h2,
h3 {
  margin: 0;
}

h1 {
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  line-height: 1;
  letter-spacing: 0;
}

.topbar p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.98rem;
}

.messages {
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.message {
  width: min(720px, 100%);
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  line-height: 1.55;
}

.message p + p {
  margin-top: 10px;
}

.message h2 {
  margin-top: 2px;
  font-size: 1.25rem;
  line-height: 1.2;
}

.message h3 {
  margin-top: 16px;
  font-size: 0.95rem;
  line-height: 1.25;
}

.message h2 + h3,
.message h3 + p,
.message h3 + ul {
  margin-top: 8px;
}

.message ul {
  margin: 8px 0 0;
  padding-left: 20px;
}

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

.message-label {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.user-message {
  align-self: flex-end;
  color: #ffffff;
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.user-message .message-label {
  color: rgba(255, 255, 255, 0.74);
}

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

.system-message {
  align-self: center;
  color: var(--warn);
  background: #fff7ed;
  border-color: #f4c89e;
}

.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 16px;
  border-top: 1px solid var(--line);
  background: rgba(251, 250, 247, 0.92);
}

textarea {
  width: 100%;
  max-height: 180px;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 15px;
  outline: none;
  line-height: 1.45;
  background: #ffffff;
}

textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 118, 109, 0.18);
}

.composer-actions {
  display: grid;
  grid-template-columns: auto auto;
  gap: 8px;
  align-items: end;
}

.icon-button,
.secondary-button,
.send-button {
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
}

.icon-button {
  width: 44px;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
}

.icon-button.is-active {
  color: #ffffff;
  background: var(--accent);
  border-color: var(--accent);
}

.secondary-button {
  padding: 0 14px;
  cursor: pointer;
}

.send-button {
  padding: 0 18px;
  color: #ffffff;
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 700;
  cursor: pointer;
}

.send-button:disabled,
.secondary-button:disabled,
.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.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;
}

@media (max-width: 720px) {
  .app-shell {
    padding: 0;
  }

  .chat-pane {
    min-height: 100vh;
    border: 0;
    border-radius: 0;
  }

  .topbar {
    padding: 18px;
  }

  .messages {
    padding: 16px;
  }

  .composer {
    grid-template-columns: 1fr;
  }

  .composer-actions {
    grid-template-columns: 1fr auto;
  }
}
