/* FPCHK assistant: chat-first layout with a sticky composer. */
.fp-chat {
  --fp-accent: #2563eb;
  /* Fills behind white icons and text stay dark blue in both themes (5.2:1 with white). */
  --fp-accent-fill: #2563eb;
  --fp-accent-soft: #eff6ff;
  --fp-surface: #ffffff;
  --fp-surface-2: #f8fafc;
  --fp-border: #e2e8f0;
  --fp-text: #0f172a;
  --fp-muted: #64748b;
  --fp-user: #2563eb;
  --fp-user-text: #ffffff;
  --fp-bot: #f1f5f9;
  --fp-wait: #b45309;
  --fp-wait-bg: #fffbeb;
  --fp-done: #047857;
  --fp-done-bg: #ecfdf5;
  --fp-stop: #b91c1c;
  --fp-stop-bg: #fef2f2;
  --fp-info: #1d4ed8;
  --fp-info-bg: #eff6ff;
  position: relative;
  display: flex;
  flex-direction: column;
  /* Fallback for phones (in-flow top bar + fixed bottom nav); chat.js fits the
     exact space left by the site chrome on load and resize. */
  height: calc(100dvh - 8rem);
  min-height: 20rem;
  max-width: 60rem;
  margin: 0 auto;
  color: var(--fp-text);
  background: var(--fp-surface);
}
.dark .fp-chat {
  --fp-accent: #60a5fa;
  --fp-accent-soft: #172554;
  --fp-surface: #111827;
  --fp-surface-2: #0b1220;
  --fp-border: #1f2937;
  --fp-text: #e5e7eb;
  --fp-muted: #9ca3af;
  --fp-user: #1d4ed8;
  --fp-bot: #1f2937;
  --fp-wait: #fbbf24;
  --fp-wait-bg: #422006;
  --fp-done: #34d399;
  --fp-done-bg: #022c22;
  --fp-stop: #f87171;
  --fp-stop-bg: #450a0a;
  --fp-info: #93c5fd;
  --fp-info-bg: #172554;
}
/* The chat fills the viewport, so the page itself never scrolls. */
.site-main:has(> .fp-chat) { padding-top: 0; padding-bottom: 0; min-height: 0; }
@media (min-width: 1024px) {
  .site-main:has(> .fp-chat) { padding-top: 1.5rem; padding-bottom: 1.5rem; }
  .fp-chat {
    height: calc(100dvh - 4.5rem - 3rem);
    border: 1px solid var(--fp-border);
    border-radius: 1rem;
    overflow: hidden;
    box-shadow: 0 10px 30px rgb(15 23 42 / 0.06);
  }
}

.fp-sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Header */
.fp-chat__bar { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .5rem .75rem; border-bottom: 1px solid var(--fp-border); }
.fp-chat__title { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.fp-chat__title > div { min-width: 0; }
.fp-chat__title h1 { font-size: 1rem; font-weight: 600; line-height: 1.3; }
.fp-chat__title p { font-size: .8125rem; color: var(--fp-muted); line-height: 1.4; }
.fp-chat__avatar { display: grid; place-items: center; width: 2.25rem; height: 2.25rem; flex: none; border-radius: .75rem; background: var(--fp-accent-fill); color: #fff; font-size: 1.3rem; }
.fp-chat__tools { display: flex; gap: .4rem; flex: none; }
.fp-chat__tool { display: inline-flex; align-items: center; gap: .3rem; min-height: 44px; padding: .35rem .65rem; border: 1px solid var(--fp-border); border-radius: .75rem; background: var(--fp-surface-2); font-size: .8rem; font-weight: 500; color: inherit; }
.fp-chat__tool:hover, .fp-chat__icon-button:hover { border-color: var(--fp-accent); }
.fp-chat__tool .material-symbols-outlined { font-size: 1.2rem; }
@media (max-width: 520px) { .fp-chat__bar { flex-wrap: wrap; } .fp-chat__tools { width: 100%; } }

/* Messages */
.fp-chat__body { position: relative; flex: 1 1 auto; display: flex; min-height: 0; }
.fp-chat__log { flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain; padding: 1rem .75rem; display: flex; flex-direction: column; gap: .75rem; background: var(--fp-surface-2); }
.fp-chat__welcome { margin: auto 0; padding: 1rem; border-radius: 1rem; background: var(--fp-surface); font-size: .95rem; line-height: 1.6; color: var(--fp-muted); }
.fp-chat__welcome[hidden] { display: none; }
.fp-chat.is-start .fp-chat__suggestions { display: none; }
.fp-chat__task-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; margin-top: 1rem; }
.fp-chat__task-grid[hidden] { display: none; }
.fp-chat__task-grid .fp-chip { justify-content: flex-start; white-space: normal; overflow-wrap: anywhere; min-height: 48px; border: 0; border-radius: .5rem; padding: .65rem .75rem; background: var(--fp-surface-2); font-size: .9rem; line-height: 1.4; text-align: left; color: var(--fp-text); }
.fp-chat__task-grid .fp-chip--accent { color: var(--fp-accent); }
.fp-chat__task-grid .fp-chip:hover { background: var(--fp-accent-soft); }
.fp-chat__more-actions { flex: none; margin: 0; padding: .75rem; max-height: 35dvh; overflow-y: auto; border-top: 1px solid var(--fp-border); }
.fp-chat__all-actions { grid-column: 1 / -1; justify-self: end; min-height: 40px; padding: .3rem .6rem; color: var(--fp-accent); font-size: .85rem; }
.fp-chat__all-actions:focus-visible { outline: 2px solid var(--fp-accent); outline-offset: -2px; }
.fp-chat__welcome-title { font-weight: 600; color: var(--fp-text); margin-bottom: .25rem; }
.fp-msg { display: flex; }
.fp-msg--user { justify-content: flex-end; }
.fp-msg__bubble { max-width: min(85%, 42rem); padding: .6rem .85rem; border-radius: 1.1rem; line-height: 1.55; overflow-wrap: anywhere; font-size: .95rem; }
.fp-msg--user .fp-msg__bubble { background: var(--fp-user); color: var(--fp-user-text); border-bottom-right-radius: .35rem; white-space: pre-wrap; }
.fp-msg--assistant .fp-msg__bubble { background: var(--fp-bot); border-bottom-left-radius: .35rem; }
.fp-msg--error .fp-msg__bubble { background: var(--fp-stop-bg); color: var(--fp-stop); }
.fp-msg__image { display: block; max-width: 12rem; max-height: 12rem; border-radius: .6rem; margin-bottom: .35rem; }
.fp-msg__file { display: inline-block; font-size: .8rem; opacity: .9; margin-bottom: .2rem; }

.fp-feedback { margin-top: .85rem; padding-top: .65rem; border-top: 1px solid var(--fp-border); font-size: .875rem; }
.fp-feedback__question { color: var(--fp-text); }
.fp-feedback__controls { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .35rem; }
.fp-feedback__button { min-height: 44px; padding: .4rem .9rem; border: 1px solid var(--fp-border); border-radius: .7rem; background: var(--fp-surface); color: var(--fp-text); }
.fp-feedback__button:hover, .fp-feedback__button[aria-pressed="true"] { border-color: var(--fp-accent); background: var(--fp-accent-soft); color: var(--fp-accent); }
.fp-feedback__button:focus-visible { outline: 2px solid var(--fp-accent); outline-offset: 2px; }
.fp-feedback__button:disabled { opacity: .5; cursor: wait; }
.fp-feedback__status { margin-top: .35rem; overflow-wrap: anywhere; }
.fp-feedback__status:empty { display: none; }

.fp-md p { margin: 0 0 .5rem; }
.fp-md p:last-child, .fp-md ul:last-child, .fp-md ol:last-child { margin-bottom: 0; }
.fp-md ul, .fp-md ol { margin: 0 0 .5rem; padding-left: 1.25rem; }
.fp-md ul { list-style: disc; }
.fp-md ol { list-style: decimal; }
.fp-md li { margin: .15rem 0; }
.fp-md a { color: var(--fp-accent); text-decoration: underline; text-underline-offset: 2px; }
.fp-md code { padding: .05rem .3rem; border-radius: .3rem; background: var(--fp-surface); font-size: .85em; }

.fp-msg--typing .fp-msg__bubble { display: inline-flex; gap: .3rem; padding: .85rem 1rem; }
.fp-typing-dot { width: .45rem; height: .45rem; border-radius: 999px; background: var(--fp-muted); animation: fp-typing 1.2s infinite ease-in-out; }
.fp-typing-dot:nth-child(2) { animation-delay: .15s; }
.fp-typing-dot:nth-child(3) { animation-delay: .3s; }
@keyframes fp-typing { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .fp-typing-dot { animation: none; } }

/* Status cards */
.fp-card { margin-top: .6rem; padding: .6rem .7rem; border-radius: .8rem; border: 1px solid var(--fp-border); border-left-width: 4px; background: var(--fp-surface); font-size: .85rem; }
.fp-card--wait { border-left-color: var(--fp-wait); }
.fp-card--done { border-left-color: var(--fp-done); }
.fp-card--stop { border-left-color: var(--fp-stop); }
.fp-card--info { border-left-color: var(--fp-info); }
.fp-card--muted { border-left-color: var(--fp-border); opacity: .75; }
.fp-card__head { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.fp-card__icon { font-size: 1.1rem; color: var(--fp-muted); }
.fp-card__title { font-weight: 600; margin-right: auto; }
.fp-badge { padding: .1rem .5rem; border-radius: 999px; font-size: .72rem; font-weight: 600; background: var(--fp-wait-bg); color: var(--fp-wait); }
.fp-card--done .fp-badge { background: var(--fp-done-bg); color: var(--fp-done); }
.fp-card--stop .fp-badge { background: var(--fp-stop-bg); color: var(--fp-stop); }
.fp-card--info .fp-badge { background: var(--fp-info-bg); color: var(--fp-info); }
.fp-card--muted .fp-badge { background: var(--fp-surface-2); color: var(--fp-muted); }
.fp-card__detail { margin-top: .25rem; color: var(--fp-muted); }
.fp-card__reply { margin-top: .35rem; padding: .4rem .5rem; border-radius: .5rem; background: var(--fp-surface-2); white-space: pre-wrap; }
.fp-card__buttons { display: flex; gap: .5rem; margin-top: .55rem; flex-wrap: wrap; }
.fp-button { min-height: 2.5rem; padding: .4rem .9rem; border-radius: .7rem; border: 1px solid var(--fp-border); background: var(--fp-surface-2); color: inherit; font-weight: 600; }
.fp-button--primary { background: var(--fp-accent-fill); border-color: var(--fp-accent-fill); color: #fff; }
.fp-button:disabled { opacity: .5; }

/* Suggestions */
.fp-chat__suggestions { display: grid; grid-template-columns: 2rem minmax(0, 1fr) 2rem; align-items: center; gap: .15rem; flex: none; min-width: 0; padding: .35rem .4rem 0; border-top: 1px solid var(--fp-border); }
.fp-chat__suggestions[hidden] { display: none; }
.fp-chat__chips { display: flex; gap: .5rem; min-width: 0; padding: .15rem .1rem .45rem; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin; scrollbar-color: var(--fp-muted) transparent; }
.fp-chat__chips::-webkit-scrollbar { height: 5px; }
.fp-chat__chips::-webkit-scrollbar-thumb { background: var(--fp-muted); border-radius: 5px; }
.fp-chat__chip-scroll { display: grid; place-items: center; min-height: 2.5rem; border: 0; border-radius: .5rem; background: var(--fp-surface-2); color: var(--fp-text); }
.fp-chat__chip-scroll:disabled { opacity: .3; cursor: default; }
.fp-chat__chips:focus-visible, .fp-chat__chip-scroll:focus-visible, .fp-chip:focus-visible { outline: 2px solid var(--fp-accent); outline-offset: -2px; }
.fp-chip { flex: none; display: inline-flex; align-items: center; min-height: 2.25rem; padding: .3rem .8rem; border-radius: 999px; border: 1px solid var(--fp-border); background: var(--fp-surface); color: inherit; font-size: .82rem; white-space: nowrap; }
.fp-chip--accent { border-color: var(--fp-accent); color: var(--fp-accent); background: var(--fp-accent-soft); }
.fp-chip:hover { border-color: var(--fp-accent); }

/* Composer */
.fp-chat__composer { position: sticky; bottom: 0; padding: .5rem .75rem .6rem; background: var(--fp-surface); }
.fp-chat__input-row { display: flex; align-items: flex-end; gap: .4rem; padding: .3rem; border: 1px solid var(--fp-border); border-radius: 1.25rem; background: var(--fp-surface-2); }
.fp-chat__input-row:focus-within { border-color: var(--fp-accent); box-shadow: 0 0 0 3px rgb(37 99 235 / .15); }
.fp-chat__input-row textarea { flex: 1 1 auto; min-width: 0; min-height: 2.5rem; max-height: 10rem; padding: .55rem .5rem; border: 0; background: transparent; color: inherit; resize: none; font-size: 1rem; line-height: 1.4; outline: none; }
.fp-chat__icon-button { display: inline-grid; place-items: center; width: 2.5rem; height: 2.5rem; flex: none; border-radius: 999px; border: 1px solid transparent; background: transparent; color: var(--fp-muted); }
.fp-chat__send { display: inline-grid; place-items: center; width: 2.5rem; height: 2.5rem; flex: none; border-radius: 999px; background: var(--fp-accent-fill); color: #fff; }
.fp-chat__send:disabled { opacity: .5; }
.fp-chat.is-busy .fp-chat__send .material-symbols-outlined { animation: fp-pulse 1s infinite; }
@keyframes fp-pulse { 50% { opacity: .4; } }
.fp-chat__hint { margin-top: .3rem; font-size: .7rem; color: var(--fp-muted); text-align: center; }
@media (pointer: coarse) { .fp-chat__hint { display: none; } }
.fp-chat__attachment { display: flex; align-items: center; gap: .5rem; margin-bottom: .4rem; padding: .3rem .4rem; border: 1px solid var(--fp-border); border-radius: .8rem; font-size: .8rem; }
.fp-chat__attachment[hidden] { display: none; }
.fp-chat__attachment img { width: 2.75rem; height: 2.75rem; object-fit: cover; border-radius: .45rem; }
.fp-chat__attachment span { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fp-chat__drop { position: absolute; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; gap: .5rem; border: 2px dashed var(--fp-accent); border-radius: 1rem; background: rgb(37 99 235 / .08); color: var(--fp-accent); font-weight: 600; pointer-events: none; }
.fp-chat__drop[hidden] { display: none; }

/* The widget and full page share every message, upload and approval control. */
html:has(.fp-chat-embed), .fp-chat-embed { height: 100%; margin: 0; overflow: hidden; }
.fp-chat--embedded { height: 100%; min-height: 0; max-width: none; margin: 0; border: 0; border-radius: 0; box-shadow: none; }
.fp-chat--embedded .fp-chat__title { display: none; }
.fp-chat--embedded .fp-chat__tools { width: 100%; justify-content: flex-end; }
.fp-chat--embedded .fp-chat__composer { padding-bottom: max(.6rem, env(safe-area-inset-bottom)); }
.fp-chat__context { display: flex; align-items: center; justify-content: space-between; gap: .4rem; padding: .25rem .5rem .25rem .75rem; border-bottom: 1px solid var(--fp-border); background: var(--fp-accent-soft); color: var(--fp-muted); font-size: .75rem; }
.fp-chat__context span { min-width: 0; }
.fp-chat__context a { color: var(--fp-accent); text-decoration: underline; text-underline-offset: 2px; }
.fp-chat__context[hidden] { display: none; }

/* My requests: a drawer on phones, a side panel on wide screens. */
.fp-chat__requests { position: absolute; inset: 0; z-index: 10; display: flex; flex-direction: column; background: var(--fp-surface); }
.fp-chat__requests[hidden] { display: none; }
.fp-chat__requests-head { display: flex; align-items: center; justify-content: space-between; padding: .5rem .75rem; border-bottom: 1px solid var(--fp-border); }
.fp-chat__requests-head h2 { font-weight: 600; }
.fp-chat__requests-list { flex: 1 1 auto; overflow-y: auto; padding: .75rem; font-size: .85rem; }
.fp-requests__section + .fp-requests__section { margin-top: 1rem; }
.fp-requests__section h3 { font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--fp-muted); }
.fp-requests__empty { margin-top: .4rem; color: var(--fp-muted); }
@media (min-width: 1024px) {
  .fp-chat__requests { position: static; flex: 0 0 20rem; border-left: 1px solid var(--fp-border); }
}
