:root {
  color-scheme: light;
  --ink: #14201d;
  --muted: #66716d;
  --line: #d9dfdc;
  --paper: #f3f5f2;
  --white: #ffffff;
  --signal: #e85d2a;
  --signal-dark: #bb431b;
  --forest: #173f35;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(20, 32, 29, 0.035) 1px, transparent 1px),
    linear-gradient(rgba(20, 32, 29, 0.035) 1px, transparent 1px),
    var(--paper);
  background-size: 32px 32px;
  font-family: "Segoe UI", Arial, sans-serif;
}

button, textarea { font: inherit; }

.shell {
  width: min(1080px, calc(100% - 40px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 24px 0 36px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  color: inherit;
  text-decoration: none;
}

.brand-mark, .avatar {
  display: grid;
  place-items: center;
  color: var(--white);
  background: var(--forest);
  font-weight: 800;
  letter-spacing: -0.04em;
}

.brand-mark { width: 42px; height: 42px; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; letter-spacing: 0.01em; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 12px; }

.mode {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.mode span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--signal);
  box-shadow: 0 0 0 4px rgba(232, 93, 42, 0.14);
}

.chat {
  width: min(760px, 100%);
  margin: 0 auto;
  padding-top: clamp(36px, 7vh, 76px);
}

.intro { margin-bottom: 42px; }
.eyebrow { margin: 0 0 12px; color: var(--signal-dark); font-size: 11px; font-weight: 800; letter-spacing: 0.14em; }

h1 {
  margin: 0;
  max-width: 650px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(39px, 7vw, 68px);
  font-weight: 400;
  line-height: 0.98;
  letter-spacing: -0.045em;
}

.intro > p:last-child { margin: 22px 0 0; color: var(--muted); font-size: 15px; }
code { padding: 2px 5px; color: var(--forest); background: #e1e7e3; border-radius: 3px; }

.messages {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 160px;
  max-height: 42vh;
  padding: 4px 4px 24px;
  overflow-y: auto;
  scrollbar-color: #b8c1bd transparent;
}

.message { display: flex; gap: 11px; align-items: flex-end; max-width: 84%; }
.message.user { align-self: flex-end; flex-direction: row-reverse; }
.avatar { flex: 0 0 32px; height: 32px; font-size: 10px; }
.user .avatar { background: var(--signal); }
.bubble { min-width: 0; }
.sender { display: block; margin: 0 0 5px 2px; color: var(--muted); font-size: 11px; font-weight: 700; }
.user .sender { text-align: right; }

.bubble p {
  margin: 0;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 3px 14px 14px 14px;
  background: var(--white);
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.user .bubble p {
  color: var(--white);
  border-color: var(--forest);
  border-radius: 14px 3px 14px 14px;
  background: var(--forest);
}

.message.pending .bubble p { color: var(--muted); font-style: italic; }

.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 10px;
  border: 1px solid #cbd3cf;
  background: var(--white);
  box-shadow: 0 14px 40px rgba(25, 46, 39, 0.09);
}

textarea {
  width: 100%;
  max-height: 140px;
  padding: 10px 9px;
  resize: none;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  line-height: 1.4;
}

textarea::placeholder { color: #929b97; }

button {
  display: flex;
  align-items: center;
  align-self: end;
  gap: 9px;
  min-height: 43px;
  padding: 0 17px;
  border: 0;
  color: var(--white);
  background: var(--signal);
  cursor: pointer;
  font-weight: 700;
}

button:hover { background: var(--signal-dark); }
button:focus-visible { outline: 3px solid rgba(232, 93, 42, 0.28); outline-offset: 2px; }
button:disabled { cursor: wait; opacity: 0.58; }
button svg { width: 18px; height: 18px; }
.notice { margin: 10px 2px 0; color: var(--muted); font-size: 11px; text-align: center; }
.confirmation { display: grid; gap: 9px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.confirmation small { color: var(--muted); line-height: 1.45; }
.confirmation button { min-height: 40px; width: fit-content; padding: 0 15px; }
.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: 620px) {
  .shell { width: min(100% - 24px, 760px); padding-top: 14px; }
  .mode { font-size: 0; }
  .intro { margin-bottom: 30px; }
  .messages { max-height: 43vh; }
  .message { max-width: 94%; }
  .composer { grid-template-columns: 1fr 46px; }
  button { justify-content: center; min-width: 46px; padding: 0; }
  button span { display: none; }
  .confirmation button { width: 100%; padding: 0 12px; }
}
