@font-face {
  font-family: "DM Sans";
  src: url("/assets/dm-sans.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}

:root {
  --forest: #12332b;
  --green: #1a624c;
  --paper: #edf2eb;
  --ink: #142b24;
  --muted: #486359;
  --border: #c6d8ce;
  font: 100%/1.4 "DM Sans", system-ui, sans-serif;
  color: var(--ink);
  background: #12201d;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body, h1, p, figure { margin: 0; }
button, input, textarea { font: inherit; }
button, label { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .53; }
:focus-visible { outline: 2px solid #339a76; outline-offset: 3px; }
.screen { width: min(100%, 825px); min-width: 0; margin: 0 auto; }

.access {
  display: grid;
  min-height: 100svh;
  place-items: center;
  padding: 28px;
  color: #f1faf6;
  background: #102e26;
}
.access form { display: grid; width: min(100%, 320px); }
.access img { width: 136px; height: auto; margin-bottom: 14px; }
.access h1 { margin: 0 0 23px; font-size: 1.8rem; letter-spacing: -.02em; }
.access label { margin-bottom: 8px; }
.access input {
  min-height: 46px;
  border: 1px solid #6a9788;
  border-radius: 9px;
  padding: 7px 12px;
  color: var(--ink);
  background: #f3faf6;
}
.access button {
  margin-top: 12px;
  min-height: 46px;
  border: 0;
  border-radius: 9px;
  color: #112e26;
  background: #5de4c7;
  font-weight: 700;
}
#access-error { margin-top: 10px; color: #ffc1aa; }
#access-error:empty { display: none; }

.chat {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  height: 100dvh;
  background: var(--paper);
}
.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px clamp(14px, 4vw, 32px);
  background: var(--forest);
  color: #f1faf6;
}
.chat-header h1 { font-size: 1.08rem; font-weight: 700; }
.chat-header p { font-size: .8rem; color: #b8d6c9; }
.avatar {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 50%;
  background: #2a5c4d;
  color: #dcfbef;
  font-size: .74rem;
  font-weight: 700;
  letter-spacing: .05em;
}
.profile {
  border-bottom: 1px solid var(--border);
  padding: 9px 16px;
  color: #214b3d;
  background: #dcebe1;
  text-align: center;
  font-size: .875rem;
}

.conversation {
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  overflow-anchor: none;
  overscroll-behavior: contain;
  scrollbar-color: #93b1a4 transparent;
  scrollbar-width: thin;
  padding: 17px clamp(17px, 4.4vw, 45px) 16px;
  background: var(--paper) url("/assets/chat-texture.webp");
}
.bubble {
  --bubble: #fff;
  position: relative;
  width: fit-content;
  max-width: min(90%, 552px);
  margin-bottom: 5px;
  padding: 8px 10px 5px;
  border-radius: 9px;
  background: var(--bubble);
  box-shadow: 0 1px 2px rgb(25 62 44 / .15);
  overflow-wrap: anywhere;
}
.bubble p { white-space: pre-line; }
.bubble.outgoing { --bubble: #d3edda; margin-left: auto; }
.bubble.tail { margin-top: 12px; border-top-left-radius: 2px; }
.bubble.tail::before {
  position: absolute;
  top: 0;
  left: -7px;
  width: 9px;
  height: 9px;
  background: var(--bubble);
  clip-path: polygon(0 0, 100% 0, 100% 100%);
  content: "";
}
.bubble.outgoing.tail { border-top-left-radius: 9px; border-top-right-radius: 2px; }
.bubble.outgoing.tail::before { right: -7px; left: auto; transform: scaleX(-1); }
.meta { display: block; margin-top: 4px; color: var(--muted); text-align: right; font-size: .75rem; font-variant-numeric: tabular-nums; }
.question-list { display: grid; gap: 9px; margin: 8px 0 0; padding-left: 1.35rem; }
.question-list li { padding-left: 2px; }
.previous { display: block; color: #205241; font-size: .89rem; }
.options { display: block; color: #455f53; font-size: .875rem; }
.review-lines { display: grid; gap: 6px; margin-top: 9px; }
.review-lines span { display: block; color: #205241; font-size: .9rem; font-weight: 700; }
.actions { display: grid; margin: 5px -10px -5px; border-top: 1px solid #deebe4; }
.actions button {
  min-height: 43px;
  padding: 7px 12px;
  border: 0;
  border-radius: 0 0 9px 9px;
  background: transparent;
  color: #155f47;
  font-weight: 700;
}
.actions button:hover:not(:disabled) { background: #edf6ee; }
.bubble a { display: inline-block; margin-top: 7px; color: #1b5e4a; text-underline-offset: 2px; }
.bubble audio { max-width: min(69vw, 310px); height: 39px; display: block; }
.bubble details { margin-top: 5px; }
.bubble summary { cursor: pointer; color: #225543; font-size: .875rem; font-weight: 650; }
.bubble details p { margin-top: 4px; }
.sent-image { display: block; max-width: min(67vw, 285px); max-height: 215px; border-radius: 7px; object-fit: contain; }

footer { min-width: 0; border-top: 1px solid var(--border); background: #eef4ee; }
#composer, #capture {
  display: flex;
  align-items: flex-end;
  min-height: 61px;
  gap: 8px;
  padding: 8px 12px max(8px, env(safe-area-inset-bottom));
}
.message-box {
  display: flex;
  align-items: flex-end;
  flex: 1;
  min-width: 0;
  padding-right: 3px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: #fff;
}
#message {
  flex: 1;
  min-width: 0;
  min-height: 43px;
  max-height: 111px;
  padding: 10px 8px 9px 15px;
  border: 0;
  border-radius: 24px;
  resize: none;
  color: var(--ink);
  background: transparent;
}
#message::placeholder { color: var(--muted); }
.round {
  display: inline-grid;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 0;
  border-radius: 50%;
}
.round svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.primary { background: var(--green); color: #fff; }
.primary:hover { background: #104c39; }
.attachment { width: 40px; height: 42px; color: #476359; cursor: pointer; }
.attachment:hover { background: #edf6ee; }
.attachment[aria-disabled="true"] { pointer-events: none; opacity: .53; }
#image { position: absolute; width: 1px; height: 1px; opacity: 0; clip-path: inset(50%); }
.message-box:has(#image:focus-visible) .attachment { outline: 2px solid #339a76; }
#activity, .failure { padding: 7px 16px 0; font-size: .875rem; }
#activity { color: #285142; }
.failure { display: flex; align-items: baseline; gap: 8px; color: #812f27; }
.failure button, #cancel {
  min-height: 42px;
  padding-inline: 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #205a45;
  font-weight: 700;
}
#capture { align-items: center; }
.record-dot { width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%; background: #bf3b43; }
#duration { min-width: 33px; font-size: .88rem; font-variant-numeric: tabular-nums; }
.wave { display: flex; flex: 1; height: 29px; align-items: center; gap: 4px; color: #269171; overflow: hidden; }
.wave i { flex: 0 0 3px; height: 13px; border-radius: 3px; background: currentColor; animation: wave .43s ease-in-out infinite alternate; }
.wave i:nth-child(3n) { height: 22px; animation-delay: -.19s; }
.wave i:nth-child(3n + 1) { height: 8px; animation-delay: -.3s; }
.wave i:nth-child(5n) { height: 16px; animation-delay: -.1s; }
@keyframes wave { from { transform: scaleY(.54); } to { transform: scaleY(1.15); } }

@media (max-width: 500px) {
  .profile { font-size: .82rem; padding-inline: 9px; }
  .chat-header { padding-block: 8px; }
  .conversation { padding-inline: 14px; }
  .bubble { max-width: 94%; }
}
@media (prefers-reduced-motion: reduce) {
  .wave i { animation: none; }
}
