/* GCE AI — full-bleed phone shell (same viewport lock as FIELD) */
:root {
  --gai-bg: #0c1522;
  --gai-panel: #15263a;
  --gai-line: rgba(148, 178, 210, 0.18);
  --gai-text: #e8f0f8;
  --gai-muted: #8aa0b8;
  --gai-accent: #3db8a8;
  --gai-accent-2: #2a9b8d;
  --gai-user: #1e3a55;
  --gai-bot: #183049;
  --gai-danger: #e36b6b;
  --gai-safe-top: env(safe-area-inset-top, 0px);
  --gai-safe-bot: env(safe-area-inset-bottom, 0px);
  --gai-h: 100dvh;
  --gai-w: 100%;
  --gai-vv-top: 0px;
  --gai-kb: 0px;
  --gai-font: "SF Pro Text", "Segoe UI", system-ui, -apple-system, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  background: var(--gai-bg);
  color: var(--gai-text);
  font-family: var(--gai-font);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
body {
  position: fixed !important;
  top: var(--gai-vv-top, 0px) !important;
  left: 0 !important;
  right: 0 !important;
  bottom: auto !important;
  width: 100% !important;
  max-width: none !important;
  height: var(--gai-h, 100dvh) !important;
  min-height: var(--gai-h, 100dvh) !important;
  max-height: var(--gai-h, 100dvh) !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
  background: var(--gai-bg) !important;
}
button, input, textarea { font: inherit; color: inherit; }
a { color: var(--gai-accent); text-decoration: none; }

.gai-app {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: auto !important;
  width: 100% !important;
  max-width: none !important;
  height: 100% !important;
  min-height: 100% !important;
  max-height: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
  background:
    radial-gradient(120% 80% at 10% -10%, rgba(61, 184, 168, 0.16), transparent 55%),
    radial-gradient(90% 70% at 100% 0%, rgba(40, 90, 140, 0.28), transparent 50%),
    var(--gai-bg);
}

.gai-screen {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.gai-screen[hidden] { display: none !important; }

/* —— Login —— */
.gai-login {
  position: relative;
  justify-content: center;
  padding: calc(16px + var(--gai-safe-top)) 16px calc(16px + var(--gai-safe-bot));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.gai-login-bg {
  position: absolute; inset: 0;
  background:
    linear-gradient(180deg, rgba(12, 21, 34, 0.15), rgba(12, 21, 34, 0.88)),
    url("/gce-ai-login-bg.jpg") center / cover no-repeat;
  opacity: 0.72;
  pointer-events: none;
}
.gai-login-inner { position: relative; width: 100%; max-width: 420px; margin: 0 auto; }
.gai-brand { text-align: center; margin-bottom: 22px; }
.gai-brand-mark {
  width: 72px;
  height: 72px;
  margin: 0 auto 12px;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}
.gai-brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.gai-brand h1 {
  margin: 0;
  font-size: 2rem;
  letter-spacing: 0.04em;
  font-weight: 720;
}
.gai-brand p {
  margin: 8px 0 0;
  color: var(--gai-muted);
  font-size: 0.95rem;
  line-height: 1.4;
}
.gai-login-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  border-radius: 18px;
  background: rgba(18, 32, 51, 0.88);
  border: 1px solid var(--gai-line);
  backdrop-filter: blur(10px);
}
.gai-field { display: flex; flex-direction: column; gap: 6px; }
.gai-field span { font-size: 0.78rem; color: var(--gai-muted); letter-spacing: 0.02em; }
.gai-field input {
  width: 100%;
  border: 1px solid var(--gai-line);
  background: rgba(8, 14, 22, 0.65);
  border-radius: 12px;
  padding: 12px 14px;
  outline: none;
}
.gai-field input:focus { border-color: rgba(61, 184, 168, 0.55); }
.gai-btn {
  border: 0;
  border-radius: 12px;
  padding: 13px 16px;
  font-weight: 650;
  cursor: pointer;
}
.gai-btn-primary {
  background: linear-gradient(180deg, var(--gai-accent), var(--gai-accent-2));
  color: #06221e;
}
.gai-btn-primary:disabled { opacity: 0.55; }
.gai-err { margin: 0; color: var(--gai-danger); font-size: 0.88rem; }
.gai-link-out {
  display: block;
  text-align: center;
  margin-top: 18px;
  color: var(--gai-muted);
  font-size: 0.9rem;
}

/* —— Chat shell: edge-to-edge —— */
.gai-chat {
  padding: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
}
.gai-top {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(8px + var(--gai-safe-top)) 12px 10px;
  border-bottom: 1px solid var(--gai-line);
  background: rgba(12, 21, 34, 0.96);
  backdrop-filter: blur(12px);
  width: 100%;
}
.gai-top-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.gai-top-brand strong { display: block; font-size: 1.05rem; letter-spacing: 0.02em; }
.gai-top-brand em {
  display: block;
  font-style: normal;
  font-size: 0.75rem;
  color: var(--gai-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 58vw;
}
.gai-top-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  object-fit: cover;
  flex: 0 0 auto;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}
.gai-top-actions { display: flex; gap: 2px; flex: 0 0 auto; }
.gai-icon-btn {
  width: 42px; height: 42px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--gai-text);
  font-size: 1.15rem;
  cursor: pointer;
}
.gai-icon-btn:active { background: rgba(255,255,255,0.06); }

.gai-sheet {
  position: absolute;
  left: 10px; right: 10px;
  top: calc(54px + var(--gai-safe-top));
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px;
  border-radius: 16px;
  background: var(--gai-panel);
  border: 1px solid var(--gai-line);
  box-shadow: 0 18px 40px rgba(0,0,0,0.35);
}
.gai-sheet[hidden] { display: none !important; }
.gai-sheet button, .gai-sheet a {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--gai-text);
  padding: 13px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.98rem;
}
.gai-sheet button:active, .gai-sheet a:active { background: rgba(255,255,255,0.06); }
.gai-sheet .is-danger { color: var(--gai-danger); }
.gai-sheet .is-muted { color: var(--gai-muted); }

.gai-log {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 12px 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.gai-empty {
  margin: auto;
  text-align: center;
  max-width: 280px;
  color: var(--gai-muted);
  padding: 24px 8px;
}
.gai-empty b {
  display: block;
  color: var(--gai-text);
  font-size: 1.15rem;
  margin-bottom: 6px;
}
.gai-bubble {
  max-width: 88%;
  padding: 11px 13px;
  border-radius: 16px;
  line-height: 1.45;
  font-size: 0.98rem;
  white-space: pre-wrap;
  word-break: break-word;
  animation: gaiIn 0.22s ease-out;
}
@keyframes gaiIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
.gai-bubble--user {
  align-self: flex-end;
  background: var(--gai-user);
  border-bottom-right-radius: 6px;
}
.gai-bubble--bot {
  align-self: flex-start;
  background: var(--gai-bot);
  border: 1px solid var(--gai-line);
  border-bottom-left-radius: 6px;
}
.gai-bubble--sys {
  align-self: center;
  max-width: 94%;
  background: transparent;
  color: var(--gai-muted);
  font-size: 0.82rem;
  text-align: center;
  padding: 4px 8px;
}
.gai-bubble.is-thinking { color: var(--gai-muted); }

.gai-cites {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.gai-cite {
  border: 1px solid rgba(61, 184, 168, 0.45);
  background: rgba(61, 184, 168, 0.14);
  color: #b7f0e6;
  border-radius: 999px;
  padding: 6px 10px;
  font: 650 11px/1.2 inherit;
  cursor: pointer;
}
.gai-cite:active { background: rgba(61, 184, 168, 0.28); }

.gai-doc {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  background: #071018;
}
.gai-doc[hidden] { display: none !important; }
.gai-doc-top {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(10px + var(--gai-safe-top)) 10px 10px;
  border-bottom: 1px solid var(--gai-line);
  background: rgba(12, 21, 34, 0.96);
}
.gai-doc-top strong {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gai-doc-body {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  background: #0a121c;
}
.gai-doc-status {
  margin: 0;
  padding: 24px 16px;
  text-align: center;
  color: var(--gai-muted);
}
.gai-doc-frame,
.gai-doc-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: #111;
}
.gai-doc-img {
  object-fit: contain;
  background: #000;
}

.gai-chips {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  width: 100%;
  padding: 4px 12px 6px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.gai-chips::-webkit-scrollbar { display: none; }
.gai-chips button {
  flex: 0 0 auto;
  border: 1px solid var(--gai-line);
  background: rgba(21, 38, 58, 0.8);
  color: var(--gai-text);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 0.82rem;
  white-space: nowrap;
  cursor: pointer;
}
.gai-chips button:active { border-color: rgba(61, 184, 168, 0.5); }

.gai-composer {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  width: 100%;
  padding: 8px 10px calc(8px + var(--gai-safe-bot));
  border-top: 1px solid var(--gai-line);
  background: rgba(12, 21, 34, 0.98);
}
body.gai-kb-open .gai-composer {
  /* keyboard already shrinks --gai-h; don't double-count home indicator */
  padding-bottom: 8px;
}
.gai-composer textarea {
  flex: 1;
  min-height: 44px;
  max-height: 120px;
  width: 100%;
  resize: none;
  border: 1px solid var(--gai-line);
  background: var(--gai-panel);
  border-radius: 14px;
  padding: 12px 14px;
  outline: none;
  line-height: 1.35;
}
.gai-composer textarea:focus { border-color: rgba(61, 184, 168, 0.45); }
.gai-send {
  width: 44px; height: 44px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(180deg, var(--gai-accent), var(--gai-accent-2));
  color: #06221e;
  display: grid;
  place-items: center;
  cursor: pointer;
  flex: 0 0 auto;
}
.gai-send:disabled { opacity: 0.45; }
