:root {
  --teal: #306f80;
  --teal-dark: #24525f;
  --teal-soft: #e3eef0;
  --cream: #f8f3ea;
  --card: #fffdf9;
  --ink: #2b3a3f;
  --muted: #607378;
  --line: #e4dccd;
  --error: #a33b2b;
  --radius: 16px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--cream);
  color: var(--ink);
  font-family: "Gothic A1", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100%;
  height: 100dvh;
  max-width: 720px;
  margin: 0 auto;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--cream);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand img { border-radius: 8px; }
.brand-name { font-weight: 700; color: var(--teal); font-size: 18px; line-height: 1.1; }
.brand-sub { font-size: 12px; color: var(--muted); }
.top-actions { display: flex; gap: 12px; }

.screen { flex: 1; overflow-y: auto; padding: 24px 16px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px 20px;
  max-width: 440px;
  margin: 4vh auto 0;
}
h1 { font-size: 24px; margin: 0 0 12px; color: var(--teal-dark); font-weight: 700; }
p { margin: 0 0 14px; }
label { display: block; font-weight: 600; margin: 8px 0 6px; font-size: 15px; }

input, textarea {
  width: 100%;
  font: inherit;
  font-size: 16px; /* stops iOS zooming in */
  color: var(--ink);
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
input:focus, textarea:focus { outline: 2px solid var(--teal); outline-offset: 1px; border-color: var(--teal); }
.code-input { font-size: 26px; letter-spacing: 8px; text-align: center; }

.btn {
  display: inline-block;
  width: 100%;
  margin-top: 14px;
  padding: 13px 18px;
  font: inherit;
  font-weight: 700;
  font-size: 16px;
  color: #fff;
  background: var(--teal);
  border: 0;
  border-radius: 12px;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { background: var(--teal-dark); }
.btn:disabled { opacity: 0.6; cursor: default; }
.small-btn { width: auto; margin: 0; padding: 6px 12px; font-size: 14px; }

.link-btn {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  font-size: 14px;
  color: var(--teal);
  text-decoration: underline;
  cursor: pointer;
}
.msg { min-height: 1.4em; margin: 10px 0 0; font-size: 15px; color: var(--error); }
.msg.ok { color: var(--teal-dark); }
.small { font-size: 14px; color: var(--muted); margin-top: 16px; }

/* Chat */
.chat { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.bubble {
  max-width: 88%;
  padding: 11px 14px;
  border-radius: 16px;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.bubble p { margin: 0 0 10px; }
.bubble p:last-child, .bubble ol:last-child, .bubble ul:last-child { margin-bottom: 0; }
.bubble ol, .bubble ul { margin: 0 0 10px; padding-left: 22px; }
.bubble li { margin-bottom: 4px; }
.bubble a { color: #306F80; font-weight: 600; text-decoration: underline; text-underline-offset: 2px; word-break: break-word; }
.bot { align-self: flex-start; background: var(--card); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.user { align-self: flex-end; background: var(--teal); color: #fff; border-bottom-right-radius: 4px; white-space: pre-wrap; }
.notice { align-self: center; text-align: center; font-size: 14px; color: var(--muted); max-width: 92%; }
.notice.error { color: var(--error); }
.typing::after { content: "…"; animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: 0.2; } }

.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px calc(10px + var(--safe-bottom));
  border-top: 1px solid var(--line);
  background: var(--cream);
}
.composer textarea { resize: none; max-height: 140px; line-height: 1.4; }
.send-btn {
  flex: 0 0 46px;
  height: 46px;
  border-radius: 50%;
  border: 0;
  background: var(--teal);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.send-btn:disabled { opacity: 0.5; cursor: default; }

.install-hint {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px 12px 0;
  padding: 10px 12px;
  background: var(--teal-soft);
  border-radius: 12px;
  font-size: 14px;
}
.install-hint span { flex: 1; }
.close-btn { background: none; border: 0; font-size: 22px; line-height: 1; color: var(--muted); cursor: pointer; padding: 0 4px; }

.safety {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  padding: 6px 16px calc(8px + var(--safe-bottom));
  border-top: 1px solid var(--line);
}
.chat ~ .safety { padding-bottom: 8px; }

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Tappable example prompts under the welcome */
.examples { display: flex; flex-wrap: wrap; gap: 8px; max-width: 88%; }
.example { font: inherit; font-size: 15px; color: #306F80; background: #fff; border: 1.5px solid #306F80; border-radius: 999px; padding: 8px 14px; cursor: pointer; text-align: left; }
.example:hover, .example:focus-visible { background: #306F80; color: #fff; outline: none; }
