:root {
  --bg: #f2f4f7;
  --panel: #ffffff;
  --line: #e4e8ee;
  --ink: #1b2330;
  --muted: #7a8598;
  --brand: #2f6bff;
  --bot: #eef1f6;
  --me: #2f6bff;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  font-size: 16px;
}

/* Single-attribute mode flip — the only thing panic touches. */
html[data-mode="cover"] #chat { display: none !important; }
html[data-mode="chat"]  #cover { display: none !important; }

#cover, #chat {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 640px;
  margin: 0 auto;
  background: var(--bg);
}

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(12px + var(--safe-t)) 16px 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 15px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #cbd2dd; }
.dot.live { background: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,.18); }
.status { font-size: 12px; color: var(--muted); }

.log {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  -webkit-overflow-scrolling: touch;
}

.msg { display: flex; }
.msg.bot, .msg.admin { justify-content: flex-start; }
.msg.me, .msg.client { justify-content: flex-end; }
.bubble {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 16px;
  line-height: 1.35;
  font-size: 15px;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg.bot .bubble, .msg.admin .bubble {
  background: var(--bot);
  color: var(--ink);
  border-bottom-left-radius: 5px;
}
.msg.me .bubble, .msg.client .bubble {
  background: var(--me);
  color: #fff;
  border-bottom-right-radius: 5px;
}
.bubble.pending { opacity: .55; font-style: italic; }

.composer {
  display: flex;
  gap: 8px;
  padding: 10px 12px calc(10px + var(--safe-b));
  background: var(--panel);
  border-top: 1px solid var(--line);
}
.composer input {
  flex: 1;
  border: 1px solid var(--line);
  background: #f7f9fc;
  border-radius: 22px;
  padding: 12px 16px;
  font-size: 16px; /* prevents iOS zoom */
  color: var(--ink);
  outline: none;
}
.composer input:focus { border-color: var(--brand); background: #fff; }
.composer button {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.composer button:active { transform: scale(.94); }

.hidebar {
  padding: 8px 12px calc(10px + var(--safe-b));
  background: var(--panel);
  border-top: 1px solid var(--line);
}
#hide-btn {
  width: 100%;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f0f3f8;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
#hide-btn:active { transform: scale(.98); }
