/* Frontpage inline chat — ChatGPT-style full-page layout */

/* ---- Full-page chat mode ---- */
/* When chat is active, the dashboard transforms: hero + cards hide,
   the assistant card fills the viewport with messages above, input below. */

.dashboard-shell.is-chatting .dashboard-hero,
.dashboard-shell.is-chatting .dashboard-work-grid {
  display: none;
}

.dashboard-shell.is-chatting {
  display: flex;
  flex-direction: column;
  /* No fixed height — let the shell grow with the messages so the outer
     .sb-main scrollbar drives the scroll. */
  min-height: 100%;
  padding-bottom: 0;
}

.dashboard-shell.is-chatting .ai-assistant-card {
  display: flex;
  flex-direction: column;
  max-width: 820px;
  width: 100%;
  margin: 0 auto;
}

.sofia-chat-prompt::placeholder{
  text-align: center !important;
}

/* ---- Conversation area ----
   In chat mode the conversation grows with its messages — no inner scrollbar.
   The page (.sb-main) scrollbar is the single source of scroll. */

.fp-chat-conversation {
  display: none;
  flex-direction: column;
  gap: 16px;
  padding: 16px 8px 16px;
  scroll-behavior: smooth;
}

.fp-chat-conversation.is-open {
  display: flex;
}

/* Chat-mode only: reserve space at the bottom of the conversation so the
   last messages don't slide behind the sticky composer when scrolled all
   the way down. */
.dashboard-shell.is-chatting .fp-chat-conversation {
  padding-bottom: 120px;
}

/* ---- Composer is fixed to the viewport bottom in chat mode ----
   Stays glued to the bottom regardless of how far the page is scrolled.
   The .sb-sidebar takes the left 112px of the viewport on desktop, so the
   composer is offset by that amount and centred (max 820px) within the
   remaining space — matching the rest of the dashboard layout. */

.dashboard-shell.is-chatting .assistant-composer {
  position: fixed;
  left: 112px;
  right: 0;
  bottom: 16px;
  max-width: 820px;
  margin-left: auto;
  margin-right: auto;
  padding-left: 24px;
  padding-right: 24px;
  z-index: 50;
}

/* Bottom-strip backdrop covers the area behind the fixed composer so
   messages scrolling past don't peek out around its rounded corners. */
.dashboard-shell.is-chatting::after {
  content: "";
  position: fixed;
  left: 112px;
  right: 0;
  bottom: 0;
  height: 96px;
  background: #f8fbfd;
  z-index: 49;
  pointer-events: none;
}

/* Soft fade above the backdrop so messages don't hit a hard edge as you
   scroll past the bottom of the conversation. */
.dashboard-shell.is-chatting::before {
  content: "";
  position: fixed;
  left: 112px;
  right: 0;
  bottom: 96px;
  height: 32px;
  background: linear-gradient(180deg, rgba(248, 251, 253, 0) 0%, #f8fbfd 100%);
  z-index: 49;
  pointer-events: none;
}

/* Mobile: sidebar slides off-screen, so the composer + backdrop span the
   full viewport width. */
@media (max-width: 1024px) {
  .dashboard-shell.is-chatting .assistant-composer,
  .dashboard-shell.is-chatting::after,
  .dashboard-shell.is-chatting::before,
  .dashboard-shell.is-chatting .fp-chat-file-bar.is-visible {
    left: 0;
  }
}

/* In chat mode the composer becomes position:fixed and the file bar — which
   normally sat above it in the card's flow — ends up either scrolled off the
   bottom of the conversation or hidden behind the ::after backdrop. Pin it
   to the viewport just above the composer with the same horizontal
   constraints (left + right + max-width + auto margins) so it tracks the
   composer's centred 820px column and stays visible while typing. z-index
   sits one above the composer so a long filename can't get clipped by it. */
.dashboard-shell.is-chatting .fp-chat-file-bar.is-visible {
  position: fixed;
  left: 112px;
  right: 0;
  bottom: 90px;
  max-width: 820px;
  margin: 0 auto;
  z-index: 51;
}

/* ---- Top row (back, new chat, history buttons) ---- */

.fp-chat-top-row {
  display: none;
  gap: 4px;
  align-items: center;
  padding: 0 0 4px;
  flex-shrink: 0;
}

.dashboard-shell.is-chatting .fp-chat-top-row {
  display: flex;
}

.fp-chat-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #657084;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: color 150ms, background 150ms;
}

.fp-chat-back:hover {
  color: #087fb2;
  background: rgba(8, 127, 178, 0.06);
}

.fp-chat-history-btn {
  margin-left: auto;
}

.fp-chat-back svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

/* Active chat title — sits between the back and history buttons. Stays empty
   on a fresh chat and gets populated either from the auto-generated title on
   first send or from the loaded conversation's saved title. */
.fp-chat-title-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0 12px;
}

.fp-chat-title-wrap.is-empty {
  display: none;
}

.fp-chat-title {
  min-width: 0;
  color: #111b34;
  font-size: 14px;
  font-weight: 650;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fp-chat-title-edit {
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #9eafc4;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
  transition: color 150ms, background 150ms;
}

.fp-chat-title-edit:hover,
.fp-chat-title-edit:focus-visible {
  color: #087fb2;
  background: rgba(8, 127, 178, 0.08);
  outline: none;
}

.fp-chat-title-edit svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.fp-chat-title-wrap.is-editing .fp-chat-title,
.fp-chat-title-wrap.is-editing .fp-chat-title-edit {
  display: none;
}

.fp-chat-title-edit-input {
  flex: 1;
  min-width: 0;
  max-width: 360px;
  padding: 4px 10px;
  border: 1px solid #cfd8e6;
  border-radius: 8px;
  background: #fff;
  color: #111b34;
  font: inherit;
  font-size: 14px;
  font-weight: 650;
  line-height: 1.3;
  text-align: center;
  outline: none;
  box-sizing: border-box;
  transition: border-color 150ms, box-shadow 150ms;
}

.fp-chat-title-edit-input:focus {
  border-color: #087fb2;
  box-shadow: 0 0 0 3px rgba(8, 127, 178, 0.18);
}

/* ---- "Previous conversations" trigger link ---- */

.fp-prev-chats-trigger {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: -8px auto 20px;
  padding: 6px 0;
  border: 0;
  background: transparent;
  color: #657084;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: color 150ms;
}

.fp-prev-chats-trigger:hover {
  color: #087fb2;
}

.fp-prev-chats-trigger svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.dashboard-shell.is-chatting .fp-prev-chats-trigger {
  display: none;
}

/* Center the trigger */
.dashboard-shell > .fp-prev-chats-trigger {
  display: flex;
  width: fit-content;
}

/* ---- Right-side slide panel ---- */

.fp-panel-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1099;
  background: rgba(14, 25, 43, 0.16);
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
}

.fp-panel-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.fp-panel {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 1100;
  width: min(420px, 100vw - 32px);
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-left: 1px solid rgba(27, 54, 86, 0.08);
  box-shadow: -16px 0 48px rgba(31, 58, 88, 0.12);
  transform: translateX(100%);
  transition: transform 260ms cubic-bezier(0.32, 0.72, 0, 1);
}

.fp-panel.is-open {
  transform: translateX(0);
}

.fp-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 28px 24px 0;
  flex-shrink: 0;
}

.fp-panel-header-text h2 {
  margin: 0;
  color: #111b34;
  font-family: Inter, system-ui, sans-serif;
  font-size: 20px;
  font-weight: 750;
  line-height: 1.25;
}

.fp-panel-header-text p {
  margin: 4px 0 0;
  color: #9eafc4;
  font-size: 13px;
  line-height: 1.4;
}

.fp-panel-close {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #657084;
  cursor: pointer;
  transition: background 150ms, color 150ms;
  flex-shrink: 0;
}

.fp-panel-close:hover {
  background: rgba(27, 54, 86, 0.06);
  color: #111b34;
}

.fp-panel-close svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

/* Search */
.fp-panel-search {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 20px 24px 0;
  padding: 0 14px;
  height: 44px;
  border: 1px solid rgba(27, 54, 86, 0.12);
  border-radius: 12px;
  background: #f8fbfd;
  flex-shrink: 0;
}

.fp-panel-search svg {
  width: 18px;
  height: 18px;
  stroke: #9eafc4;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  flex-shrink: 0;
}

.fp-panel-search input {
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  color: #111b34;
  font-size: 14px;
}

.fp-panel-search input::placeholder {
  color: #9eafc4;
}

/* Conversation list */
.fp-panel-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0 24px;
}

.fp-panel-group-label {
  padding: 18px 24px 8px;
  color: #657084;
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.fp-panel-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 24px;
  border: 0;
  background: transparent;
  cursor: pointer;
  text-align: left;
  transition: background 150ms;
  position: relative;
}

.fp-panel-item:hover {
  background: rgba(8, 127, 178, 0.04);
}

.fp-panel-item-text {
  flex: 1;
  min-width: 0;
}

.fp-panel-item-title {
  display: block;
  color: #111b34;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fp-panel-item-date {
  display: block;
  margin-top: 2px;
  color: #9eafc4;
  font-size: 12px;
}

.fp-panel-item-actions {
  display: none;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.fp-panel-item:hover .fp-panel-item-actions,
.fp-panel-item.is-editing .fp-panel-item-actions {
  display: flex;
}

.fp-panel-item-edit,
.fp-panel-item-delete {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #9eafc4;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
  transition: color 150ms, background 150ms;
}

.fp-panel-item-edit:hover {
  color: #087fb2;
  background: rgba(8, 127, 178, 0.08);
}

.fp-panel-item-delete:hover {
  color: #e53e3e;
  background: rgba(229, 62, 62, 0.06);
}

.fp-panel-item-edit svg,
.fp-panel-item-delete svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

/* Inline rename input — replaces the .fp-panel-item-title <span> while
   editing. Matches the title typography so the row doesn't reflow. */
.fp-panel-item-edit-input {
  display: block;
  width: 100%;
  margin: -4px 0;
  padding: 4px 8px;
  border: 1px solid #cfd8e6;
  border-radius: 8px;
  background: #fff;
  color: #111b34;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
  outline: none;
  box-sizing: border-box;
  transition: border-color 150ms, box-shadow 150ms;
}

.fp-panel-item-edit-input:focus {
  border-color: #087fb2;
  box-shadow: 0 0 0 3px rgba(8, 127, 178, 0.18);
}

.fp-panel-item-edit-input:disabled {
  opacity: 0.6;
  cursor: progress;
}

.fp-panel-empty {
  padding: 40px 24px;
  text-align: center;
  color: #9eafc4;
  font-size: 14px;
}

.fp-panel-loading {
  padding: 40px 24px;
  text-align: center;
  color: #9eafc4;
  font-size: 14px;
}

/* ---- Shared bubble base ---- */

.fp-chat-msg {
  max-width: 80%;
  padding: 14px 18px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.55;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  animation: fp-chat-fade-in 200ms ease;
}

@keyframes fp-chat-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* AI message — frosted card style */
.fp-chat-msg--ai {
  align-self: flex-start;
  color: #1a2740;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(27, 54, 86, 0.1);
  box-shadow: 0 8px 24px rgba(31, 58, 88, 0.06);
  backdrop-filter: blur(10px);
  border-bottom-left-radius: 6px;
  position: relative;
}

/* User message — teal gradient matching send button */
.fp-chat-msg--user {
  align-self: flex-end;
  color: #fff;
  background: linear-gradient(180deg, #25a8d0 0%, #087fb2 100%);
  box-shadow: 0 8px 20px rgba(8, 143, 190, 0.18);
  border-bottom-right-radius: 6px;
  position: relative;
}

/* Plain text wrapper inside a user bubble (so absolute-positioned action
   buttons sit alongside the text without disrupting flow). */
.fp-chat-msg-text {
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* ---- Markdown inside AI messages ---- */

.fp-chat-msg--ai .markdown-body {
  background: transparent !important;
  font-size: inherit;
  font-family: inherit;
  color: #1a2740 !important;
  overflow-x: auto;
}

.fp-chat-msg--ai .markdown-body p {
  margin: 0 0 10px;
}

.fp-chat-msg--ai .markdown-body p:last-child {
  margin-bottom: 0;
}

.fp-chat-msg--ai .markdown-body ul,
.fp-chat-msg--ai .markdown-body ol {
  margin: 6px 0;
  padding-left: 20px;
}

.fp-chat-msg--ai .markdown-body li {
  margin-bottom: 4px;
}

.fp-chat-msg--ai .markdown-body strong {
  color: #101a31;
  font-weight: 700;
}

.fp-chat-msg--ai .markdown-body a {
  color: #087fb2;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.fp-chat-msg--ai .markdown-body code {
  padding: 2px 6px;
  border-radius: 5px;
  background: rgba(27, 54, 86, 0.06);
  font-size: 0.9em;
}

.fp-chat-msg--ai .markdown-body pre {
  padding: 12px 14px;
  border-radius: 10px;
  background: rgba(27, 54, 86, 0.05);
  overflow-x: auto;
}

.fp-chat-msg--ai .markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0;
}

.fp-chat-msg--ai .markdown-body th,
.fp-chat-msg--ai .markdown-body td {
  padding: 8px 10px;
  border: 1px solid rgba(27, 54, 86, 0.1);
  text-align: left;
  font-size: 14px;
}

.fp-chat-msg--ai .markdown-body th {
  background: rgba(27, 54, 86, 0.04);
  font-weight: 700;
}

/* ---- Action row (copy + TTS) on messages ---- */

.fp-chat-msg-actions {
  position: static;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  pointer-events: auto;
}

.fp-chat-msg-actions button {
  min-height: 32px;
  padding: 0 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: rgba(20, 32, 45, 0.54);
  cursor: pointer;
  font: inherit;
  font-size: 12.5px;
  font-weight: 560;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.fp-chat-msg-actions button:hover,
.fp-chat-msg-actions button:focus-visible {
  background: rgba(30, 41, 59, 0.05);
  color: rgba(20, 32, 45, 0.88);
  outline: none;
  transform: translateY(-1px);
}

.fp-chat-msg-actions button:active {
  transform: translateY(0);
}

/* AI message buttons — light surface to contrast with the white-ish bubble */
.fp-chat-msg--ai .fp-chat-copy,
.fp-chat-msg--ai .fp-chat-tts {
  color: rgba(20, 32, 45, 0.54);
}

.fp-chat-msg--ai .fp-chat-copy:hover,
.fp-chat-msg--ai .fp-chat-tts:hover {
  background: rgba(30, 41, 59, 0.05);
  color: rgba(20, 32, 45, 0.88);
}

/* User message buttons — translucent white on the teal gradient bubble */
.fp-chat-msg--user .fp-chat-copy,
.fp-chat-msg--user .fp-chat-tts {
  color: rgba(20, 32, 45, 0.54);
}

.fp-chat-msg--user .fp-chat-copy:hover,
.fp-chat-msg--user .fp-chat-tts:hover {
  background: rgba(30, 41, 59, 0.05);
  color: rgba(20, 32, 45, 0.88);
}

/* Icons — colour follows currentColor so both variants inherit correctly */
.fp-chat-msg-actions svg {
  width: 16px;
  height: 16px;
  pointer-events: none;
}

.fp-chat-action-icon {
  width: 16px;
  height: 16px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
}

.fp-chat-action-label {
  line-height: 1;
}

/* Copy SVG uses fill, the others use stroke — both follow currentColor */
.fp-chat-copy svg {
  fill: currentColor;
}

/* Speaker icon: polygon is filled (speaker body), the two arc <path>s are
   stroke-only (the sound waves) — both follow currentColor. */
.fp-chat-tts svg {
  fill: currentColor;
  stroke: currentColor;
}

.fp-chat-tts svg path {
  fill: none;
}

.fp-chat-tts[data-state="loading"] svg {
  animation: fp-chat-tts-spin 0.85s linear infinite;
}

.fp-chat-tts[data-state="playing"] {
  /* keep visible after hover ends — handled by :has() rule above */
  background: rgba(31, 127, 155, 0.1) !important;
  color: #1f7f9b !important;
}

.fp-chat-msg--user .fp-chat-tts[data-state="playing"] {
  background: rgba(31, 127, 155, 0.1) !important;
  color: #1f7f9b !important;
}

.fp-chat-copy.is-copied {
  background: rgba(31, 127, 155, 0.08) !important;
  color: #1f7f9b !important;
}

.fp-chat-msg--user .fp-chat-copy.is-copied {
  background: rgba(31, 127, 155, 0.08) !important;
  color: #1f7f9b !important;
}

@keyframes fp-chat-tts-spin {
  to { transform: rotate(360deg); }
}

/* ---- Typing indicator ---- */

.fp-chat-typing {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 14px 22px;
  border-radius: 18px;
  border-bottom-left-radius: 6px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(27, 54, 86, 0.1);
  box-shadow: 0 8px 24px rgba(31, 58, 88, 0.06);
  backdrop-filter: blur(10px);
  animation: fp-chat-fade-in 200ms ease;
}

.fp-chat-typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9eafc4;
  animation: fp-typing-bounce 1.4s infinite ease-in-out both;
}

.fp-chat-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.fp-chat-typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes fp-typing-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* ---- File indicator chip ---- */

.fp-chat-file-bar {
  display: none;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 14px;
  margin: 0 0 8px;
  border-radius: 14px;
  background: rgba(232, 247, 251, 0.7);
  border: 1px solid rgba(42, 159, 192, 0.18);
  font-size: 13px;
  color: #0b6f96;
  flex-shrink: 0;
  transition: background 150ms, border-color 150ms, color 150ms;
}

.fp-chat-file-bar.is-visible {
  display: flex;
}

/* State: reading — muted background, spinner spinning */
.fp-chat-file-bar.is-reading {
  background: rgba(231, 236, 244, 0.85);
  border-color: rgba(75, 96, 120, 0.18);
  color: #475569;
}

/* State: ready — subtle green accent */
.fp-chat-file-bar.is-ready {
  background: rgba(220, 246, 232, 0.85);
  border-color: rgba(22, 163, 74, 0.22);
  color: #166534;
}

.fp-chat-file-bar.is-ready .fp-chat-file-bar-icon {
  background: rgba(22, 163, 74, 0.14);
}

.fp-chat-file-bar.is-ready .fp-chat-file-bar-icon svg {
  stroke: #16a34a;
}

/* State: error — red border + tint */
.fp-chat-file-bar.is-error {
  background: rgba(254, 226, 226, 0.7);
  border-color: rgba(220, 38, 38, 0.32);
  color: #b91c1c;
}

.fp-chat-file-bar.is-error .fp-chat-file-bar-icon {
  background: rgba(220, 38, 38, 0.12);
}

.fp-chat-file-bar.is-error .fp-chat-file-bar-icon svg {
  stroke: #dc2626;
}

.fp-chat-file-bar-icon {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: rgba(42, 159, 192, 0.1);
  flex-shrink: 0;
  transition: background 150ms;
}

.fp-chat-file-bar-icon svg {
  width: 18px;
  height: 18px;
  stroke: #0b8bbf;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  transition: stroke 150ms;
}

.fp-chat-file-bar-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.fp-chat-file-bar-name {
  font-weight: 700;
  font-size: 13px;
  color: inherit;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-wrap: auto;
}

.fp-chat-file-bar-meta {
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.01em;
  opacity: 0.82;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Spinner — only visible during 'reading'. The SVG inside spins. */
.fp-chat-file-bar-spinner {
  width: 18px;
  height: 18px;
  display: none;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.fp-chat-file-bar.is-reading .fp-chat-file-bar-spinner {
  display: inline-flex;
}

.fp-chat-file-bar-spinner svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  fill: none;
  animation: fp-chat-file-spin 0.9s linear infinite;
}

@keyframes fp-chat-file-spin {
  to { transform: rotate(360deg); }
}

.fp-chat-file-bar button {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  color: #9eafc4;
  flex-shrink: 0;
  transition: color 150ms, background 150ms;
}

.fp-chat-file-bar.is-error button {
  color: #b91c1c;
}

.fp-chat-file-bar.is-ready button {
  color: #16a34a;
}

.fp-chat-file-bar button:hover {
  color: #e53e3e;
  background: rgba(229, 62, 62, 0.08);
}

.fp-chat-file-bar button svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

/* Hidden file input */
.fp-chat-file-input {
  display: none;
}

/* ---- Responsive ---- */

@media (max-width: 760px) {
  .dashboard-shell.is-chatting .ai-assistant-card {
    margin-bottom: 0;
  }

  .fp-panel {
    width: 100vw;
  }

  .fp-chat-msg {
    max-width: 92%;
    padding: 12px 14px;
    font-size: 14px;
  }
}

/* ---- Top-row responsive: collapse the back / history buttons to icon-only
        on phones so the active chat title in the middle has room. The labels
        "Ny chat" / "Tidligere samtaler" (and their English equivalents)
        combined run ~220px wide, which crowds the title and forces wrapping
        on a 360px viewport. Below 640px we drop the text and tighten the
        button padding to a square hit-area; SVG icons alone communicate
        the actions clearly. ---- */
@media (max-width: 640px) {
  .fp-chat-top-row {
    gap: 2px;
    padding: 0 0 2px;
  }

  .dashboard-shell.is-chatting .assistant-composer {
    margin: 0 16px;
  }

  .fp-chat-back {
    padding: 8px;
    gap: 0;
    font-size: 0; /* hides the inline whitespace around the inner span */
  }

  /* Inner label spans (the textContent populated from i18n) — hide them so
     only the SVG icon remains. We don't `display: none` the whole span
     because the JS still reads/updates its textContent for i18n live swaps. */
  .fp-chat-back > span {
    display: none;
  }

  /* Keep the SVG at its usual size; restore the font baseline by setting
     line-height explicitly so the icon still vertically aligns. */
  .fp-chat-back svg {
    width: 18px;
    height: 18px;
  }

  /* Title middle column: tighter side padding so it gets the recovered
     horizontal room, and keeps its existing ellipsis truncation. */
  .fp-chat-title-wrap {
    padding: 0 6px;
  }

  .fp-chat-title {
    font-size: 13px;
  }

  /* The pencil edit-title button is already 26×26; shrink slightly so it
     doesn't dominate the row alongside the smaller icon buttons. */
  .fp-chat-title-edit {
    width: 24px;
    height: 24px;
  }
}

/* When the user is actively chatting on the frontpage (state flipped by
   enterChatMode() in frontpage-chat.js), hide the floating-chat trigger.
   The trigger lives as a sibling of .dashboard-shell — both are appended
   directly to <body> — so we key the rule off the body-level class.
   Also hide the floating window itself in case it was open. */
body.fp-chat-active .sb-float-trigger,
body.fp-chat-active .sb-float-window {
  display: none !important;
}

/* Dashboard-to-Sofia handoff continuity. */
.sofia-dashboard-hero {
  view-transition-name: sofia-surface;
}

.sofia-dashboard-hero .dashboard-smart-composer,
.sofia-dashboard-hero .sofia-composer {
  view-transition-name: sofia-composer;
}

body.fp-chat-handoff-loading .sofia-dashboard-hero {
  opacity: 0.92;
  transform: translateY(-2px) scale(1.01);
  border-radius: 28px;
  transition:
    opacity 180ms ease,
    transform 220ms cubic-bezier(0.22, 1, 0.36, 1),
    border-radius 220ms ease;
}

body.fp-chat-handoff-loading .dashboard-active-stack {
  opacity: 0;
  transform: translateY(8px);
  transition:
    opacity 160ms ease,
    transform 180ms cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .sofia-dashboard-hero,
  .sofia-dashboard-hero .dashboard-smart-composer,
  .sofia-dashboard-hero .sofia-composer,
  body.fp-chat-handoff-loading .sofia-dashboard-hero,
  body.fp-chat-handoff-loading .dashboard-active-stack {
    animation: none !important;
    transition-duration: 0.001ms !important;
    transform: none !important;
  }
}

/* Dedicated chat composer field. frontpage-chat.js converts the CMS-rendered
   <textarea id="sofia-chat-prompt"> into a single-line <input> so the field is
   always vertically centred (no multi-row growth). The textarea-specific rules
   (.sofia-composer textarea / .assistant-composer textarea) no longer match an
   <input>, so mirror that borderless, transparent look here, keyed off the
   preserved id. The composer grid's align-items:center handles the vertical
   centring of the single line. */
#sofia-chat-prompt {
  width: 100%;
  min-width: 0;
  height: 44px;
  margin: 0;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: #17212b;
  font-size: 16px;
  line-height: 1.4;
  text-overflow: ellipsis;
}

#sofia-chat-prompt::placeholder {
  color: rgba(75, 88, 105, 0.78);
  opacity: 1;
}

/* ── Drag-and-drop file upload on the Sofia composer ─────────────────────────
   Highlight + hint appear only while a file is dragged over the composer
   (.is-dropzone toggled by frontpage-chat.js). Reuses the teal design accent. */
.assistant-composer.is-dropzone {
  position: relative;
  outline: 2px dashed var(--accent, #168ca4);
  outline-offset: 3px;
  background: rgba(22, 140, 164, 0.06);
}
.assistant-composer.is-dropzone::after {
  content: attr(data-drop-hint);
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: inherit;
  background: rgba(22, 140, 164, 0.1);
  color: #0f7f97;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  padding: 0 16px;
  pointer-events: none;
  z-index: 5;
}
