/* George AI: a quiet reading companion, with room left for the page. */
.gf-assistant {
  --gf-ai-ink: #27282c;
  --gf-ai-muted: #7b7e85;
  --gf-ai-paper: #fdfdfb;
  --gf-ai-accent: #52629b;
  --gf-ai-line: #e9eae6;
  position: relative;
  z-index: 999;
}
.gf-assistant [hidden] { display: none !important; }
.gf-assistant *, .gf-assistant *::before, .gf-assistant *::after { box-sizing: border-box; }
.gf-assistant button, .gf-assistant textarea, .gf-assistant input { font: inherit; }
.gf-assistant button { cursor: pointer; }
.gf-assistant button:disabled { cursor: wait; opacity: .4; }
.gf-assistant button:focus-visible, .gf-assistant a:focus-visible, .gf-assistant input:focus-visible {
  outline: 2px solid var(--gf-ai-accent);
  outline-offset: 3px;
}

.gf-assistant__launcher {
  position: fixed;
  right: 24px;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  z-index: 1002;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  min-width: 0;
  padding: 0;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 50%;
  background: #292c32;
  color: #fff;
  box-shadow: 0 3px 14px rgba(28,32,43,.16);
  transition: transform .2s ease, background .2s ease;
}
.gf-assistant__launcher:hover { transform: translateY(-2px); background: #424754; }
.gf-assistant__launcher-icon { display: block; }
.gf-assistant__launcher-copy { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.gf-assistant__backdrop { display: none; }

.gf-assistant__panel {
  position: fixed;
  right: 24px;
  bottom: calc(82px + env(safe-area-inset-bottom, 0px));
  z-index: 1003;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(400px, calc(100vw - 32px));
  height: min(560px, calc(100dvh - 108px));
  overflow: hidden;
  border: 1px solid #e1e3df;
  border-radius: 18px;
  background: var(--gf-ai-paper);
  color: var(--gf-ai-ink);
  box-shadow: 0 16px 60px rgba(25,31,46,.13), 0 2px 8px rgba(25,31,46,.04);
  animation: gf-ai-enter .22s ease-out both;
}
@keyframes gf-ai-enter { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.gf-assistant__header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 15px 16px 13px; border-bottom: 1px solid var(--gf-ai-line); }
.gf-assistant__identity { display: flex; align-items: center; gap: 10px; min-width: 0; }
.gf-assistant__monogram { display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid #e5e6e1; border-radius: 50%; background: #f4f5ef; color: #555c4e; font-family: var(--display-serif, Georgia, serif); font-size: 24px; line-height: 1; font-style: italic; }
.gf-assistant__identity h2 { margin: 0 0 3px; color: var(--gf-ai-ink); font-family: inherit; font-size: 16px; font-weight: 600; line-height: 1.2; letter-spacing: -.035em; }
.gf-assistant__identity p { margin: 0; color: var(--gf-ai-muted); font-size: 10px; line-height: 1.4; }
.gf-assistant__header-actions { display: flex; align-items: center; gap: 7px; }
.gf-assistant__header-actions button { min-height: 32px; padding: 5px 7px; border: 0; border-radius: 7px; background: none; color: #70747d; font-size: 11px; }
.gf-assistant__header-actions button:hover { background: #f0f1ef; color: var(--gf-ai-ink); }
.gf-assistant__header-actions .gf-assistant__close { width: 30px; padding: 0; font-family: sans-serif; font-size: 22px; font-weight: 300; line-height: 1; }
.gf-assistant__disclaimer { margin: 0; padding: 0 15px 11px; color: #989ba1; font-size: 9px; line-height: 1.45; text-align: center; }

.gf-assistant__view { min-height: 0; min-width: 0; }
.gf-assistant__view[data-gf-ai-chat-view] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto auto auto; }
.gf-assistant__conversation-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 0; padding: 7px 16px; }
.gf-assistant__conversation-bar strong { min-width: 0; overflow: hidden; color: var(--gf-ai-muted); font-size: 10px; font-weight: 400; white-space: nowrap; text-overflow: ellipsis; }
.gf-assistant__conversation-bar button { flex-shrink: 0; min-height: 30px; padding: 4px 0 4px 8px; border: 0; background: none; color: #666e82; font-size: 10px; }
.gf-assistant__conversation-bar button:hover { color: var(--gf-ai-accent); }
.gf-assistant__conversation-bar button span { font-size: 13px; }
.gf-assistant__messages { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 10px 18px 0; scrollbar-width: thin; scrollbar-color: #d9dcd7 transparent; }
.gf-assistant__welcome { padding: 16px 3px 12px; }
.gf-assistant__welcome-mark { display: grid; place-items: center; width: 44px; height: 44px; margin-bottom: 18px; border-radius: 13px; background: #f0f2ea; color: #606856; font-family: var(--display-serif, Georgia, serif); font-size: 34px; font-style: italic; line-height: 1; }
.gf-assistant__welcome h3 { margin: 0 0 11px; color: var(--gf-ai-ink); font-family: var(--display-serif, Georgia, serif); font-size: 25px; font-weight: 400; letter-spacing: -.045em; line-height: 1.35; }
.gf-assistant__welcome p { max-width: 310px; margin: 0; color: #81858a; font-size: 12px; line-height: 1.8; }
.gf-assistant__message { max-width: 100%; margin: 0 0 20px; }
.gf-assistant__message--user { width: fit-content; max-width: 90%; margin-left: auto; padding: 10px 13px; border-radius: 12px 12px 3px 12px; background: #eff1f4; color: #3d4350; }
.gf-assistant__speaker { display: block; margin-bottom: 7px; color: #91959e; font-family: var(--mono, monospace); font-size: 8px; font-weight: 500; letter-spacing: .06em; }
.gf-assistant__message--user .gf-assistant__speaker { display: none; }
.gf-assistant__message p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; line-height: 1.8; }
.gf-assistant__progress { display: flex; align-items: center; gap: 7px; margin-bottom: 8px; color: #82899a; font-size: 10px; }
.gf-assistant__message.is-streaming .gf-assistant__progress::before { content: ''; width: 10px; height: 10px; border: 1.5px solid #dce0e8; border-top-color: #6b7799; border-radius: 50%; animation: gf-ai-spin 1s linear infinite; }
.gf-assistant__message.is-streaming p:not(:empty)::after { content: '▍'; color: #a0a8bc; animation: gf-ai-pulse 1.2s ease-in-out infinite; }
.gf-assistant__message[data-gf-ai-unsaved] .gf-assistant__progress { color: #a95d50; }
@keyframes gf-ai-spin { to { transform: rotate(360deg); } }
@keyframes gf-ai-pulse { 50% { opacity: .3; } }

.gf-assistant__sources { display: grid; gap: 5px; margin-top: 12px; }
.gf-assistant__source { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 7px; align-items: center; padding: 9px; border: 1px solid var(--gf-ai-line); border-radius: 9px; background: #f8f9f6; color: inherit; text-decoration: none; }
.gf-assistant__source:hover { border-color: #c8ccd7; }
.gf-assistant__source span { font-family: var(--mono, monospace); color: #8790a9; font-size: 9px; }
.gf-assistant__source strong { overflow: hidden; color: #697181; font-size: 10px; font-weight: 500; line-height: 1.4; text-overflow: ellipsis; white-space: nowrap; }
.gf-assistant__source small { color: #9c9fa7; font-size: 8px; }
.gf-assistant__suggestions { display: grid; gap: 6px; padding: 7px 18px 12px; }
.gf-assistant__suggestions button { width: 100%; min-height: 34px; padding: 9px 12px; border: 1px solid #eceee9; border-radius: 9px; background: #f8f9f5; color: #777e78; font-size: 11px; line-height: 1.4; text-align: left; }
.gf-assistant__suggestions button::after { content: '↗'; float: right; padding-left: 7px; color: #a7ada4; }
.gf-assistant__suggestions button:hover { border-color: #d1d7c9; background: #f1f4ed; color: #535e4b; }
.gf-assistant__composer { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: end; margin: 0 14px; padding: 7px 7px 7px 12px; border: 1px solid #dfe2dc; border-radius: 12px; background: #fff; }
.gf-assistant__composer:focus-within { border-color: #b8c1d0; box-shadow: 0 0 0 2px rgba(97,113,149,.05); }
.gf-assistant__composer textarea { width: 100%; min-height: 32px; max-height: 100px; resize: none; padding: 6px 0; border: 0; outline: 0; box-shadow: none; background: transparent; color: var(--gf-ai-ink); font-size: 12px; line-height: 1.6; }
.gf-assistant__composer textarea::placeholder { color: #a3a8a2; }
.gf-assistant__composer button { display: grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 8px; background: #454e42; color: #fff; }
.gf-assistant__composer button span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.gf-assistant__composer button i { font-style: normal; font-size: 16px; }
.gf-assistant__composer.is-disabled { opacity: .65; }
.gf-assistant__footer { display: flex; justify-content: space-between; gap: 12px; padding: 7px 17px 9px; color: #a2a5ac; font-size: 8px; line-height: 1.5; }
.gf-assistant__older, .gf-assistant__more { justify-self: center; margin: 0 auto 8px; padding: 6px 10px; border: 0; background: none; color: #80899e; font-size: 10px; }

.gf-assistant__view[data-gf-ai-history-view] { overflow-y: auto; overscroll-behavior: contain; padding: 15px 18px; scrollbar-width: thin; }
.gf-assistant__history-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.gf-assistant__history-head button { min-height: 28px; padding: 0; border: 0; background: none; color: #7f8798; font-size: 10px; }
.gf-assistant__history-head > button:last-child { padding-left: 8px; }
.gf-assistant__view[data-gf-ai-history-view] h3 { margin: 0 0 9px; color: var(--gf-ai-ink); font-family: var(--display-serif, Georgia, serif); font-size: 25px; font-weight: 400; letter-spacing: -.035em; line-height: 1.3; }
.gf-assistant__history-note { margin: 0 0 15px; color: #969aa0; font-size: 10px; line-height: 1.7; }
.gf-assistant__history-status { min-height: 14px; margin: 0 0 3px; color: #7e8b73; font-size: 10px; line-height: 1.5; }
.gf-assistant__history { display: grid; gap: 4px; font-size: 12px; color: #969aa0; }
.gf-assistant__history-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 6px; padding: 6px 9px; border: 1px solid transparent; border-bottom-color: var(--gf-ai-line); border-radius: 8px; }
.gf-assistant__history-item.is-current { border-color: #e2e6dc; background: #f4f6ef; }
.gf-assistant__history-open { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; width: 100%; padding: 8px 0; border: 0; background: none; text-align: left; }
.gf-assistant__history-open strong { display: block; max-width: 100%; overflow: hidden; color: #5d646a; font-size: 11px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.gf-assistant__history-open small { margin-top: 5px; color: #a2a7ad; font-size: 9px; }
.gf-assistant__history-actions { display: flex; align-items: center; gap: 2px; }
.gf-assistant__history-actions button { min-height: 32px; padding: 5px; border: 0; border-radius: 5px; background: none; color: #a1a6ac; font-size: 9px; }
.gf-assistant__history-actions button:hover { background: #ebeee6; color: #5d6953; }
.gf-assistant__history-actions .gf-assistant__history-delete:hover { color: #a95d50; }
.gf-assistant__history-editor { grid-column: 1 / -1; margin: 3px 0 5px; padding-top: 10px; border-top: 1px solid var(--gf-ai-line); }
.gf-assistant__history-editor label { display: block; color: #83888f; font-size: 11px; line-height: 1.6; }
.gf-assistant__history-editor input { display: block; width: 100%; min-width: 0; margin-top: 6px; padding: 9px; border: 1px solid #dfe3d9; border-radius: 7px; background: #fff; color: var(--gf-ai-ink); font-size: 12px; }
.gf-assistant__history-editor > div { display: flex; justify-content: flex-end; gap: 8px; margin-top: 9px; }
.gf-assistant__history-editor button { min-height: 32px; padding: 7px 12px; border: 1px solid var(--gf-ai-line); border-radius: 7px; background: #fff; color: #78806f; font-size: 10px; }
.gf-assistant__history-editor button[type=submit] { border-color: transparent; background: #606b55; color: #fff; }
.gf-assistant__history-editor button.is-danger { background: #a96b5f; }
.gf-assistant__logout { display: inline-block; margin-top: 18px; color: #90978a; font-size: 10px; }
.gf-assistant__logout:hover { color: #535e4b; }

/* Keep the surrounding article scrollable while the companion is open. */
.logged-in-as { color: var(--ink-soft); font-size: 12px; }
.form-submit { margin-bottom: 0; }
@media (max-width: 680px) {
  .gf-assistant__launcher { right: 14px; bottom: calc(14px + env(safe-area-inset-bottom, 0px)); width: 42px; height: 42px; }
  .gf-assistant__panel { right: 12px; bottom: calc(68px + env(safe-area-inset-bottom, 0px)); width: min(400px, calc(100vw - 24px)); height: min(560px, 72dvh); border-radius: 16px; }
  .gf-assistant__header { padding: 12px; }
  .gf-assistant__identity { gap: 8px; }
  .gf-assistant__identity p { font-size: 9px; }
  .gf-assistant__header-actions { gap: 3px; }
  .gf-assistant__header-actions button { padding-inline: 5px; font-size: 10px; }
  .gf-assistant__source { grid-template-columns: 26px minmax(0, 1fr); }
  .gf-assistant__source small { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .gf-assistant__panel, .gf-assistant__message.is-streaming .gf-assistant__progress::before, .gf-assistant__message.is-streaming p:not(:empty)::after { animation: none; }
  .gf-assistant *, .gf-assistant *::before, .gf-assistant *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
