/* Same visual language as the editor: calm, one teal accent, messenger bubbles.
   In-flow surfaces are flat with a hairline. Only the composer floats. */

:root {
  color-scheme: light dark;
  --bg: #f3f6f5;
  --surface: #ffffff;
  --fg: #182725;
  --muted: #53635f;
  --line: #d3dedb;
  --accent: #2c6e63;
  --accent-ink: #ffffff;
  --err: #a4302a;
  --person: #d9ebe6;
  --helper: #ffffff;
  --field: color-mix(in srgb, var(--muted) 70%, var(--surface));
  --raise: 0 1px 2px rgb(16 40 36 / .06), 0 8px 28px rgb(16 40 36 / .12);
  --s1: .25rem; --s2: .5rem; --s3: 1rem; --s4: 1.5rem; --s5: 2rem; --s6: 3rem;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  --font-display: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --t-small: .875rem;
  --t-body: 1.0625rem;
  --t-lead: 1.25rem;
  --t-title: clamp(1.75rem, 1.45rem + 1.5vw, 2.25rem);
  --r-bubble: 1.25rem; --r-card: 1rem; --r-control: .75rem;
  --target: 2.75rem;
  --dur-quick: 120ms; --dur-calm: 200ms;
  --ease-out: cubic-bezier(.2, .7, .2, 1);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111917;
    --surface: #1a2523;
    --fg: #e3ebe9;
    --muted: #9aaeaa;
    --line: #2c3b38;
    --accent: #6bb5a6;
    --accent-ink: #0b1d19;
    --err: #f2948c;
    --person: #1f3f38;
    --helper: #1a2523;
    --raise: 0 1px 2px rgb(0 0 0 / .3), 0 8px 28px rgb(0 0 0 / .45);
  }
}
@media (prefers-reduced-motion: reduce) {
  :root { --dur-quick: 0ms; --dur-calm: 0ms; }
  .spinner { animation: none; }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh; background: var(--bg); color: var(--fg);
  font: var(--t-body)/1.55 var(--font); overflow-wrap: break-word;
}
main {
  max-width: 40rem; margin: 0 auto;
  padding: var(--s4) max(var(--s3), env(safe-area-inset-right)) var(--s6) max(var(--s3), env(safe-area-inset-left));
}
main > section + section { margin-top: var(--s5); }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.2; margin: 0 0 var(--s2); }
h1 { font-size: var(--t-title); font-weight: 650; letter-spacing: -.015em; margin-bottom: var(--s3); }
h2 { font-size: var(--t-lead); font-weight: 600; }
p { margin: 0 0 var(--s3); }
a { color: var(--accent); text-underline-offset: .2em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap; border: 0;
}
.small { font-size: var(--t-small); color: var(--muted); }
.lead { font-size: var(--t-lead); color: var(--muted); line-height: 1.4; }
.error { color: var(--err); }

input, select, textarea, button { font: inherit; color: inherit; }
textarea {
  width: 100%; min-height: var(--target); padding: var(--s2) var(--s3);
  background: var(--surface); border: 1px solid var(--field); border-radius: var(--r-control);
  font-size: max(16px, 1em); line-height: 1.5; resize: vertical;
  transition: border-color var(--dur-quick) ease;
}
textarea:focus-visible { border-color: var(--accent); outline-offset: 0; }
select {
  width: auto; min-height: var(--target); padding: 0 var(--s2);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-control);
  font-size: 16px;
}
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: var(--target); padding: var(--s2) var(--s3);
  background: var(--surface); color: var(--fg); border: 1px solid var(--field); border-radius: var(--r-control);
  font-weight: 550; line-height: 1.2; text-align: center; text-decoration: none; cursor: pointer;
  transition: background-color var(--dur-quick) ease, border-color var(--dur-quick) ease, transform var(--dur-quick) ease;
}
button:not(:disabled):hover, .btn:hover { border-color: var(--accent); }
button:not(:disabled):active, .btn:active { transform: scale(.98); }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn-primary:not(:disabled):hover { background: color-mix(in srgb, var(--accent) 88%, var(--fg)); }
.btn-quiet { background: transparent; border-color: transparent; color: var(--accent); padding-inline: var(--s2); }
.btn-quiet:hover { border-color: transparent; text-decoration: underline; text-underline-offset: .2em; }
.btn-call { background: var(--err); color: var(--bg); border-color: var(--err); font-weight: 600; text-decoration: none; }
.btn-call:hover { text-decoration: none; border-color: var(--err); background: color-mix(in srgb, var(--err) 88%, var(--fg)); }
.actions { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; margin: var(--s3) 0 0; }
.inline { display: inline-flex; gap: var(--s2); align-items: center; margin: 0; }
.home-start { width: 100%; max-width: 20rem; }
.boundary {
  margin-top: var(--s5); padding: var(--s3);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card);
}

.topbar {
  position: sticky; top: 0; z-index: 2; isolation: isolate;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s1) var(--s3);
  padding: max(var(--s2), env(safe-area-inset-top)) max(var(--s3), env(safe-area-inset-right))
           var(--s2) max(var(--s3), env(safe-area-inset-left));
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.brand {
  display: inline-flex; align-items: center; gap: var(--s2); min-height: var(--target);
  font-family: var(--font-display); font-weight: 650; color: var(--fg); text-decoration: none;
}
.brand::before {
  content: "e"; content: "e" / "";
  display: inline-grid; place-items: center; width: 1.75rem; height: 1.75rem;
  border-radius: .5rem; background: var(--accent); color: var(--accent-ink); font-size: 1.05rem; line-height: 1;
  padding-bottom: .12em;
}
.bar-end { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s1) var(--s2); }
.bar-back {
  display: inline-flex; align-items: center; min-height: var(--target); padding-inline: var(--s2);
  color: var(--fg); font-weight: 550; text-decoration: none;
}
.bar-back:hover { color: var(--accent); }
.bar-title {
  flex: 1 1 auto; min-width: 0; margin: 0;
  font-family: var(--font-display); font-weight: 650; font-size: var(--t-body);
}

main:has(.conv) { padding-top: var(--s2); padding-bottom: 0; }
.conv { display: flex; flex-direction: column; min-height: calc(100dvh - 4.5rem); }
.chat { display: flex; flex-direction: column; gap: var(--s3); flex: 1 0 auto; padding: var(--s2) 0 var(--s3); }
.msg, .rating { scroll-margin-bottom: 8rem; }
.msg { display: flex; flex-direction: column; gap: var(--s1); max-width: 100%; }
.msg-person { align-items: flex-end; }
.msg-helper { align-items: flex-start; }
.bubble {
  max-width: min(34rem, 92%); padding: var(--s2) var(--s3);
  border-radius: var(--r-bubble); border: 1px solid transparent;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.bubble-person { background: var(--person); border-bottom-right-radius: .375rem; }
.bubble-helper { background: var(--helper); border-color: var(--line); border-bottom-left-radius: .375rem; }
.dot-note { margin: var(--s1) 0 0; }

.points {
  display: flex; gap: var(--s2); max-width: 100%;
  overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: var(--s1);
  isolation: isolate;
}
.point-card {
  flex: none; width: 9.5rem; scroll-snap-align: start;
  color: inherit; text-decoration: none;
}
.point-card img {
  display: block; width: 9.5rem; height: 9.5rem; object-fit: cover;
  border-radius: var(--r-card); border: 1px solid var(--line); background: var(--surface);
}
.point-card span { display: block; margin-top: var(--s1); font-size: var(--t-small); font-weight: 550; }
.point-card:hover img { border-color: var(--accent); }

.help {
  display: grid; grid-template-columns: 7.5rem minmax(0, 1fr); gap: var(--s3); align-items: center;
  margin-top: var(--s2); padding: var(--s3);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card);
  isolation: isolate;
}
.help-images { display: flex; gap: var(--s2); }
.help-images img {
  width: 7.5rem; height: 7.5rem; object-fit: cover; border-radius: var(--r-control); background: var(--bg);
}
.help h2 { margin-bottom: var(--s1); }
.help p { margin-bottom: var(--s2); }
.help-emergency { border-color: var(--err); }
.help-emergency h2 { color: var(--err); }
@media (max-width: 32rem) {
  .help { grid-template-columns: 1fr; }
  .help-images { display: grid; grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr)); }
  .help-images img { width: 100%; height: 10rem; }
}

#point-view {
  width: min(36rem, calc(100vw - 2rem)); max-height: calc(100dvh - 2rem);
  padding: var(--s3); border: 1px solid var(--line); border-radius: var(--r-card);
  background: var(--surface); color: var(--fg);
}
#point-view::backdrop { background: rgb(16 40 36 / .45); }
#point-view img { display: block; width: 100%; height: auto; max-height: calc(100dvh - 8rem); object-fit: contain; border-radius: var(--r-control); }
#point-view p { margin: var(--s2) 0 0; font-weight: 550; }
#point-view form { display: flex; justify-content: flex-end; margin: 0 0 var(--s2); }

.pending { margin: var(--s2) 0 var(--s3); }
.spinner {
  display: inline-block; width: .8em; height: .8em; border: 2px solid var(--muted); border-right-color: transparent;
  border-radius: 50%; vertical-align: -.1em; animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
button:disabled, textarea:disabled { opacity: .55; cursor: not-allowed; }

.rating { margin: var(--s2) 0 var(--s3); }
.rates { display: flex; flex-wrap: wrap; gap: var(--s1); }
.rates button { width: var(--target); padding: 0; }

.composer {
  position: sticky; bottom: 0; z-index: 2; isolation: isolate;
  display: grid; gap: var(--s2);
  margin: var(--s3) calc(-1 * var(--s3)) 0;
  padding: var(--s2) var(--s3) calc(var(--s2) + env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--line); box-shadow: var(--raise);
}
.composer-input { display: flex; align-items: flex-end; gap: var(--s2); }
.composer-input textarea { flex: 1; min-width: 0; min-height: var(--target); max-height: 40dvh; resize: none; border-radius: 1.375rem; }
#send { flex: none; border-radius: 999px; }
@media (min-width: 40rem) {
  .composer { margin-inline: 0; border: 1px solid var(--line); border-radius: var(--r-card) var(--r-card) 0 0; }
}
