/* Installation chat: built for an engineer's phone at the charger first, then widened for desktop.
   Layout idea: a fixed bar, one centred column, and a chat that fills the screen with the message
   box pinned to the bottom. */
:root {
  --navy: #102440;
  --ink: #152238;
  --muted: #5b6b80;
  --line: #dbe3ec;
  --accent: #215bd8;
  --ok: #147a54;
  --bg: #edf2f8;
  --surface: #ffffff;
  --agent-bubble: #eaf1f9;
  --user-bubble: #d6f2e3;
  font-family: "Segoe UI", Roboto, system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

*, *::before, *::after { box-sizing: border-box; }
/* Author display rules (flex, grid) would otherwise beat the hidden attribute. */
[hidden] { display: none !important; }

html, body { height: 100%; margin: 0; }
body { background: var(--bg); -webkit-text-size-adjust: 100%; }

.app {
  height: 100%;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

.bar {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top));
  background: var(--navy);
  color: #fff;
}
.brand { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.logo { font-weight: 850; font-size: 22px; letter-spacing: -1px; }
.dot { color: #4bd39c; font-size: 10px; margin-left: 2px; vertical-align: middle; }
.title { font-size: 15px; color: #c8d5e6; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-button[aria-pressed="true"] {
  background: #b45309;
  border-color: #b45309;
}
.bar-button {
  flex: none;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  background: transparent;
  border: 1px solid #55758d;
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
}

.content {
  flex: 1;
  min-height: 0;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

/* Sign-in */
.card {
  margin: 16px;
  padding: 24px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
}
.card h1 { margin: 0 0 6px; font-size: 22px; }
.hint { margin: 0 0 20px; color: var(--muted); font-size: 15px; line-height: 1.45; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.stack label { font-size: 14px; font-weight: 700; color: #3d5470; }
input, textarea {
  font: inherit;
  font-size: 16px; /* below 16px iOS zooms the page on focus */
  color: var(--ink);
  width: 100%;
  border: 1px solid #c4d1e0;
  border-radius: 12px;
  padding: 12px 14px;
  background: #fff;
}
.status { margin: 14px 0 0; min-height: 1.4em; font-size: 15px; line-height: 1.45; color: #3d5470; }

button.primary {
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: 12px;
  padding: 13px 18px;
  min-height: 48px;
  cursor: pointer;
}
button.primary:disabled { opacity: .55; cursor: default; }
button.link {
  font: inherit;
  font-size: 15px;
  align-self: flex-start;
  background: none;
  border: 0;
  padding: 6px 0;
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
}
button:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 3px solid #7aa7f5;
  outline-offset: 2px;
}

/* Chat */
.chat {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
}
.messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.bubble {
  max-width: 88%;
  padding: 11px 14px;
  border-radius: 16px;
  font-size: 15px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.bubble.agent { align-self: flex-start; background: var(--agent-bubble); border-bottom-left-radius: 4px; }
.bubble.user { align-self: flex-end; background: var(--user-bubble); border-bottom-right-radius: 4px; }
.meta { font-size: 12px; font-weight: 700; color: #526c85; margin-bottom: 3px; }
.bubble a { color: inherit; text-decoration: underline; }
.reply-video { display: block; width: 100%; max-width: 320px; max-height: 60vh; margin: 8px 0; border-radius: 10px; background: #000; }
.reply-image { display: block; width: 100%; max-width: 420px; margin: 8px 0; border-radius: 10px; }
.reply-media-link { display: block; margin: 8px 0; }

.confirm-card {
  align-self: stretch;
  border: 2px solid var(--accent);
  background: #fff;
  border-radius: 16px;
  padding: 14px;
  font-size: 15px;
  line-height: 1.5;
}
.confirm-card.confirmed { border-color: var(--ok); }
.confirm-card.cancelled { border-color: #9aa8b5; }
.confirm-buttons { display: flex; gap: 10px; margin-top: 12px; }
.confirm-buttons button {
  flex: 1;
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  min-height: 48px;
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
}
.confirm-buttons button.secondary { background: var(--agent-bubble); color: var(--ink); }
.confirm-buttons button:disabled { opacity: .5; cursor: default; }

/* What the assistant is doing right now, then a small "Checked 3 things" the engineer can open. */
.steps { align-self: flex-start; max-width: 88%; font-size: 14px; color: var(--muted); }
.steps summary { cursor: pointer; padding: 2px 0; }
.steps[open] summary { display: none; }
.steps.finished[open] summary { display: list-item; }
.step { display: flex; align-items: center; gap: 8px; padding: 3px 0; line-height: 1.35; }
.step-mark { flex: none; width: 14px; height: 14px; display: inline-flex; align-items: center; justify-content: center; }
.step.running { color: var(--ink); }
.step.running .step-mark {
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: step-spin .8s linear infinite;
}
.step.done .step-mark::before { content: "✓"; color: var(--ok); font-weight: 800; }
.step-time { color: #8695a6; font-variant-numeric: tabular-nums; }
@keyframes step-spin { to { transform: rotate(360deg); } }

.typing { flex: none; padding: 4px 16px 8px; font-size: 14px; color: var(--muted); }
.composer {
  flex: none;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 10px 12px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.composer textarea { resize: none; min-height: 48px; max-height: 140px; line-height: 1.4; }
.composer button { flex: none; }

.sr { position: absolute; left: -99999px; }

/* Wider screens: the column floats as a card instead of filling the window. */
@media (min-width: 800px) {
  .content { padding: 24px 0; }
  .card { margin: 0; padding: 32px; }
  .chat { border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
  .bubble { max-width: 75%; }
  .confirm-card { align-self: flex-start; max-width: 75%; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
  .step.running .step-mark { animation-duration: 3s; }
}
