/* Cal's AI guest chat, from launchpad-core web/src/guest/guest.css. Phone first, light and dark from the device. */
:root {
  --bg: #fbfaf7;
  --fg: #1f2023;
  --muted: #6b6d72;
  --line: #e4e1da;
  --card: #ffffff;
  --mine: #e7eefb;
  --mine-fg: #1b2a44;
  --accent: #2f62c9;
  --accent-fg: #ffffff;
  --err: #b3261e;
  --err-bg: #fcebea;
  --code: #f2f0eb;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17181b;
    --fg: #e9e8e5;
    --muted: #9a9ca1;
    --line: #2d2f33;
    --card: #202226;
    --mine: #263552;
    --mine-fg: #e6ecf8;
    --accent: #7aa2f0;
    --accent-fg: #0f1520;
    --err: #f2b8b5;
    --err-bg: #3a1f1e;
    --code: #2a2c31;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

.g-top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--line);
}
.g-brand { color: var(--fg); text-decoration: none; font-weight: 600; }
#clerk-user:empty { display: none; }

.g-main {
  width: 100%; max-width: 760px; margin: 0 auto; padding: 16px;
}
/* The chat fills the screen: header, a log that scrolls, the composer at the bottom. */
body:has(.g-main[data-screen="chat"]) { height: 100dvh; overflow: hidden; }
.g-main[data-screen="chat"] {
  flex: 1; min-height: 0; display: flex; flex-direction: column; padding-bottom: 0;
}

#clerk-signin, .signin-wrap { display: flex; justify-content: center; padding: 0 16px 24px; }
#clerk-signin:empty { display: none; }

.g-h1 { font-size: 1.25rem; line-height: 1.3; margin: 0; overflow-wrap: anywhere; }
.g-lead { font-size: 1.05rem; margin: 24px 0; }
.g-quiet { color: var(--muted); margin: 24px 0; }
.g-note { color: var(--muted); font-size: 0.85rem; margin: 2px 0 0; }
.g-error {
  color: var(--err); background: var(--err-bg); border-radius: 8px; padding: 8px 12px; margin: 8px 0; font-size: 0.95rem;
}
.g-error[hidden] { display: none; }
.g-btn {
  font: inherit; padding: 8px 16px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--fg);
}

.g-chats { list-style: none; padding: 0; margin: 16px 0; display: grid; gap: 8px; }
.g-chat-link {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--card);
  color: var(--fg); text-decoration: none;
}
.g-chat-title { overflow-wrap: anywhere; }
.g-chat-state { color: var(--muted); font-size: 0.85rem; white-space: nowrap; }

.g-chat-head { padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.g-back { display: inline-block; color: var(--accent); text-decoration: none; font-size: 0.9rem; margin-bottom: 4px; }

.g-log { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 12px 0; overscroll-behavior: contain; }
.g-msg { display: flex; flex-direction: column; margin: 10px 0; max-width: 100%; }
.g-msg.g-guest { align-items: flex-end; }
.g-msg.g-claude { align-items: flex-start; }
.g-bubble { max-width: min(88%, 640px); min-width: 0; border-radius: 16px; padding: 8px 14px; overflow-wrap: anywhere; }
.g-guest .g-bubble { background: var(--mine); color: var(--mine-fg); border-bottom-right-radius: 4px; }
.g-claude .g-bubble { background: var(--card); border: 1px solid var(--line); border-bottom-left-radius: 4px; max-width: 100%; }
.g-guest .g-body { white-space: pre-wrap; }
.g-pending .g-bubble { opacity: 0.7; }
.g-meta { color: var(--muted); font-size: 0.75rem; margin: 2px 6px 0; }

/* Claude's markdown */
.g-body.md > :first-child { margin-top: 0; }
.g-body.md > :last-child { margin-bottom: 0; }
.g-body.md p, .g-body.md ul, .g-body.md ol { margin: 0.5em 0; }
.g-body.md ul, .g-body.md ol { padding-left: 1.3em; }
.g-body.md h1, .g-body.md h2, .g-body.md h3 { font-size: 1.05rem; margin: 0.8em 0 0.3em; }
.g-body.md a { color: var(--accent); }
.g-body.md code { background: var(--code); border-radius: 4px; padding: 0 4px; font-size: 0.9em; }
.g-body.md pre { background: var(--code); border-radius: 8px; padding: 8px 10px; overflow-x: auto; max-width: 100%; }
.g-body.md pre code { background: none; padding: 0; }
.g-body.md table { border-collapse: collapse; display: block; overflow-x: auto; max-width: 100%; font-size: 0.9rem; }
.g-body.md th, .g-body.md td { border: 1px solid var(--line); padding: 4px 8px; text-align: left; }
.g-body.md img { max-width: 100%; }
.g-body.md blockquote { margin: 0.5em 0; padding-left: 10px; border-left: 3px solid var(--line); color: var(--muted); }

.g-status:empty { display: none; }
.g-status { padding: 6px 0; }
.g-working { color: var(--muted); font-size: 0.9rem; display: flex; align-items: center; gap: 8px; }
.g-preview {
  color: var(--muted); font-size: 0.85rem; margin-top: 2px; padding-left: 10px; border-left: 2px solid var(--line);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere;
}
.g-dots { display: inline-flex; gap: 3px; }
.g-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: g-blink 1.2s infinite ease-in-out; }
.g-dots i:nth-child(2) { animation-delay: 0.2s; }
.g-dots i:nth-child(3) { animation-delay: 0.4s; }
@keyframes g-blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .g-dots i { animation: none; opacity: 0.6; } }

.g-composer {
  display: flex; gap: 8px; align-items: flex-end;
  padding: 10px 0; padding-bottom: max(12px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line); background: var(--bg);
}
.g-input {
  flex: 1; min-width: 0; resize: none; font: inherit; font-size: 16px; /* 16px stops iOS zooming in on focus */
  padding: 9px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--fg);
  max-height: 200px;
}
.g-input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.g-send {
  font: inherit; font-weight: 600; padding: 9px 16px; border-radius: 12px; border: 0; background: var(--accent); color: var(--accent-fg);
}
