/* 改一下 — one frosted panel, bottom-right. Sits UNDER the host app's own modals (z 40 < their 50+). */
.gai { --ink: #1d1d1f; --ink2: #6e6e73; --ink3: #8e8e93; --hair: rgba(0,0,0,.08); --glass: rgba(255,255,255,.8); --glass2: rgba(255,255,255,.94);
  --red: #c0261a; --green: #1f7a45; --blue: #2c5e8c; --mute: rgba(0,0,0,.05); --shadow: 0 1px 2px rgba(0,0,0,.05), 0 12px 32px rgba(0,0,0,.12);
  --right: max(18px, env(safe-area-inset-right)); --bottom: calc(var(--gai-bottom, 18px) + env(safe-area-inset-bottom));
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Helvetica Neue", "Microsoft YaHei", sans-serif; color: var(--ink); font-size: 14px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
.gai *, .gai *::before, .gai *::after { box-sizing: border-box; }
.gai button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
.gai [hidden] { display: none !important; }
.gai .gai-grow { flex: 1 1 auto; }
.gai .gai-mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-variant-numeric: tabular-nums; }
.gai .gai-row { display: flex; align-items: center; gap: 8px; }
.gai .gai-row.end { justify-content: flex-end; }

/* the collapsed button */
.gai-pill { position: fixed; left: 0; right: 0; margin: 0 auto; width: max-content; bottom: var(--bottom); z-index: 40; display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 13px 0 11px; border-radius: 999px;
  background: var(--glass); -webkit-backdrop-filter: saturate(180%) blur(18px); backdrop-filter: saturate(180%) blur(18px); border: 1px solid var(--hair); box-shadow: var(--shadow);
  color: var(--ink); font-size: 13px; font-weight: 500; letter-spacing: .01em; white-space: nowrap; transition: transform .16s ease, background .16s ease; }
.gai-pill:hover { background: var(--glass2); transform: translateY(-1px); }
.gai-pill:active { transform: scale(.97); }
.gai-pill.locked { color: var(--ink3); }
.gai-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; }
.gai-dot.live { background: #0a84ff; animation: gai-blink 1.2s ease-in-out infinite; }
.gai-dot.ok { background: var(--green); }
@keyframes gai-blink { 50% { opacity: .35; } }

/* drawing layer: only intercepts the page while the brush is on; finished circles stay visible */
.gai-draw { position: fixed; inset: 0; z-index: 39; pointer-events: none; touch-action: none; }
.gai-draw.active { pointer-events: auto; cursor: crosshair; }
.gai-draw svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; display: block; }
.gai-draw path { fill: none; stroke: #c0261a; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; opacity: .92; }

/* the panel */
.gai-panel { position: fixed; left: 0; right: 0; margin: 0 auto; bottom: var(--bottom); z-index: 41; width: min(560px, calc(100vw - 2 * var(--right))); border-radius: 18px; padding: 10px 14px 12px;
  background: var(--glass2); -webkit-backdrop-filter: saturate(180%) blur(22px); backdrop-filter: saturate(180%) blur(22px); border: 1px solid var(--hair); box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 8px; animation: gai-up .18s cubic-bezier(.2,.8,.2,1); transform-origin: bottom center; max-height: calc(100vh - var(--bottom) - 24px); }
.gai-panel.drop { outline: 2px dashed rgba(0,0,0,.18); outline-offset: -6px; }
@keyframes gai-up { from { transform: translateY(8px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
.gai-head { min-height: 26px; }
.gai-status { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 500; }
.gai-status .gai-mono { font-size: 12px; color: var(--ink3); font-weight: 400; }
.gai-status .gai-ok { color: var(--green); display: inline-flex; }
.gai-status .gai-dim { color: var(--ink3); font-weight: 500; }
.gai-eff { display: inline-flex; padding: 2px; border-radius: 8px; background: var(--mute); }
.gai-eff button { height: 20px; padding: 0 8px; border-radius: 6px; font-size: 11.5px; color: var(--ink2); }
.gai-eff button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.10); font-weight: 500; }
.gai-ib { display: inline-flex; width: 32px; height: 32px; align-items: center; justify-content: center; border-radius: 9px; color: var(--ink2); cursor: pointer; }
.gai-ib:hover { background: var(--mute); color: var(--ink); }
.gai-ib.on { background: var(--ink); color: #fff; }
.gai-ib.sm { width: 26px; height: 26px; border-radius: 7px; color: var(--ink3); }
.gai-menu-wrap { position: relative; display: inline-flex; }
.gai-menu { position: absolute; right: 0; top: 30px; z-index: 2; min-width: 220px; padding: 6px; border-radius: 12px; background: #fff; border: 1px solid var(--hair); box-shadow: var(--shadow); display: flex; flex-direction: column; }
.gai-menu button { text-align: left; padding: 8px 10px; border-radius: 8px; font-size: 13px; color: var(--ink2); white-space: nowrap; }
.gai-menu button:hover { background: var(--mute); color: var(--ink); }

/* the thread: what is happening, above the composer */
.gai-thread { display: flex; flex-direction: column; gap: 8px; overflow: auto; padding: 2px 0 4px; border-bottom: 1px solid var(--hair); }
.gai-quote { font-size: 12.5px; color: var(--ink3); white-space: pre-wrap; max-height: 40px; overflow: hidden; }
.gai-steps { display: flex; flex-direction: column; gap: 5px; }
.gai-step { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; line-height: 18px; }
.gai-step.done { color: var(--ink3); }
.gai-step.done svg { color: var(--ink3); flex: none; margin-top: 2px; }
.gai-step.run { color: var(--ink); }
.gai-step.note { color: var(--ink3); padding-left: 22px; font-size: 12px; }
.gai-hint { color: var(--ink3); font-size: 12px; line-height: 16px; flex: 1 1 auto; min-width: 0; }
.gai-step span { white-space: pre-wrap; }
.gai-spin { flex: none; width: 13px; height: 13px; margin-top: 2px; border-radius: 50%; border: 2px solid rgba(0,0,0,.12); border-top-color: var(--ink); animation: gai-spin .9s linear infinite; display: inline-block; }
@keyframes gai-spin { to { transform: rotate(360deg); } }
.gai-reply { font-size: 14.5px; line-height: 21px; display: flex; flex-direction: column; gap: 6px; letter-spacing: -.005em; }
.gai-reply p { margin: 0; }
.gai-meta { font-size: 11.5px; color: var(--ink3); }
.gai-link { font-size: 12.5px; color: var(--blue); text-decoration: none; white-space: nowrap; }
.gai-link:hover { text-decoration: underline; }
.gai-btn { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--hair); background: rgba(255,255,255,.7); color: var(--ink); font-size: 13.5px; font-weight: 500; text-decoration: none; }
.gai-btn:hover { background: #fff; }
.gai-btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); padding: 0 18px; }
.gai-btn.primary:hover { background: #000; }
.gai-btn:disabled { opacity: .35; cursor: default; }
.gai-fail { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.gai-fail b { color: var(--red); font-weight: 600; }
.gai-details summary { font-size: 12px; color: var(--ink3); cursor: pointer; }
.gai-details pre { margin: 6px 0 0; padding: 8px 10px; background: var(--mute); border-radius: 8px; font-size: 11px; line-height: 1.5; white-space: pre-wrap; max-height: 160px; overflow: auto; color: var(--ink2); }

/* the composer */
.gai-composer { display: flex; flex-direction: column; gap: 6px; }
.gai-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.gai-chip { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 4px 0 8px; border-radius: 999px; background: rgba(192,38,26,.08); color: var(--red); font-size: 12px; max-width: 100%; }
.gai-chip i { width: 6px; height: 6px; border-radius: 50%; background: var(--red); flex: none; }
.gai-chip b { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gai-chip button { display: inline-flex; width: 18px; height: 18px; align-items: center; justify-content: center; border-radius: 50%; color: var(--red); opacity: .7; }
.gai-chip button:hover { opacity: 1; background: rgba(192,38,26,.12); }
.gai-composer textarea { width: 100%; resize: none; border: 0; outline: 0; background: transparent; font: inherit; font-size: 16px; line-height: 22px; color: var(--ink); padding: 4px 0 2px; max-height: 160px; }
.gai-composer textarea::placeholder { color: var(--ink3); }
.gai-drawhint { font-size: 12px; color: var(--ink3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gai-imgs { display: inline-flex; gap: 6px; }
.gai-img { position: relative; width: 32px; height: 32px; border-radius: 8px; overflow: hidden; border: 1px solid var(--hair); }
.gai-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gai-img button { position: absolute; top: -1px; right: -1px; width: 16px; height: 16px; border-radius: 0 0 0 8px; background: var(--ink); color: #fff; display: inline-flex; align-items: center; justify-content: center; }
.gai-send { display: inline-flex; width: 34px; height: 34px; align-items: center; justify-content: center; border-radius: 10px; background: var(--ink); color: #fff; }
.gai-send:disabled { opacity: .35; cursor: default; }

/* locked */
.gai-panel.gai-locked { width: min(340px, calc(100vw - 2 * var(--right))); bottom: calc(var(--bottom) + 46px); gap: 10px; padding: 14px 16px 12px; }
.gai-panel.gai-locked b { font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.gai-text { font-size: 13px; line-height: 19px; color: var(--ink2); }

/* toast */
.gai-toast { position: fixed; left: 0; right: 0; margin: 0 auto; width: max-content; bottom: calc(var(--bottom) + 46px); z-index: 42; padding: 8px 14px; border-radius: 999px; background: var(--ink); color: #fff; font-size: 13px; box-shadow: var(--shadow); white-space: nowrap; max-width: calc(100vw - 2 * var(--right)); overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 640px) {
  .gai { --right: 12px; }
  .gai-panel { width: calc(100vw - 24px); }
  .gai-drawhint { display: none; }
}
@media (prefers-reduced-motion: reduce) { .gai * { animation: none !important; transition: none !important; } }
/* files attached to a request: chips above the textarea; a thumbnail for images */
.gai-files { display: flex; flex-wrap: wrap; gap: 6px; }
.gai-file { display: inline-flex; align-items: center; gap: 7px; height: 30px; padding: 0 4px 0 6px; border-radius: 9px; background: var(--mute); color: var(--ink); font-size: 12.5px; max-width: 260px; }
.gai-file img { width: 22px; height: 22px; border-radius: 5px; object-fit: cover; flex: none; }
.gai-file-ic { display: inline-flex; color: var(--ink2); flex: none; }
.gai-file b { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.gai-file small { color: var(--ink3); font-size: 11px; white-space: nowrap; }
.gai-file.up { opacity: .55; }
.gai-file.err small { color: var(--red); }
.gai-file button { display: inline-flex; width: 20px; height: 20px; align-items: center; justify-content: center; border-radius: 50%; color: var(--ink3); flex: none; }
.gai-file button:hover { background: rgba(0,0,0,.08); color: var(--ink); }
.gai-quote-files { display: flex; flex-wrap: wrap; gap: 6px; margin: -4px 0 8px; }
.gai-quote-files span { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--ink2); background: var(--mute); border-radius: 7px; padding: 3px 8px; max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gai-quote.more { margin-top: 6px; }
