/* Dedicated Sofia conversation workspace. */

.sb-main:has(> .sofia-chat-page) {
  padding-top: 0;
  padding-right: 0;
  padding-bottom: 0;
  padding-left: 232px;
  background:
    radial-gradient(circle at 50% -12%, rgba(42, 159, 192, 0.065), transparent 34%),
    linear-gradient(180deg, #fbfdff 0%, #f8fbfd 56%, #f4f8fb 100%);
}


.sofia-chat-page {
  --sofia-page-bg: #f7f9f9;
  --sofia-text: #17212b;
  --sofia-muted: rgba(23, 33, 43, 0.6);
  --sofia-soft: rgba(23, 33, 43, 0.44);
  --sofia-border: rgba(30, 41, 59, 0.075);
  --sofia-teal: #1f7f9b;
  --sofia-thread-width: 840px;
  --sofia-response-width: 740px;
  --sofia-header-width: 1040px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  color: var(--sofia-text);
  background:
    radial-gradient(circle at 12% 0%, rgba(42, 159, 192, 0.055), transparent 30%),
    radial-gradient(circle at 88% 100%, rgba(74, 160, 132, 0.045), transparent 34%),
    var(--sofia-page-bg);
  view-transition-name: sofia-surface;
}

.sofia-chat-page,
.sofia-chat-page * {
  box-sizing: border-box;
}

.sofia-chat-page .sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.sofia-chat-header {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 58px;
  min-height: 58px;
  display: flex;
  align-items: center;
  padding: 0;
  background: rgba(247, 249, 249, 0.78);
  border-bottom: 1px solid rgba(30, 41, 59, 0.055);
  backdrop-filter: blur(22px) saturate(140%);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
}

.sofia-chat-header-inner {
  width: min(var(--sofia-header-width), calc(100% - 48px));
  height: 100%;
  min-height: 0;
  margin-inline: auto;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
}

.sofia-chat-back-link,
.sofia-chat-header-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: rgba(20, 32, 45, 0.68);
  font: inherit;
  font-size: 13.5px;
  font-weight: 560;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition:
    color 160ms ease,
    background 160ms ease,
    transform 160ms cubic-bezier(0.22, 1, 0.36, 1);
}

.sofia-chat-back-link {
  justify-self: start;
  width: 38px;
  height: 38px;
  min-height: 38px;
  display: grid;
  place-items: center;
  padding: 0;
}

.sofia-chat-header-button {
  padding: 0;
}

.sofia-chat-back-link:hover,
.sofia-chat-back-link:focus-visible,
.sofia-chat-header-button:hover,
.sofia-chat-header-button:focus-visible {
  color: rgba(20, 32, 45, 0.92);
  background: rgba(30, 41, 59, 0.05);
  outline: none;
}

.sofia-chat-back-link:active,
.sofia-chat-header-button:active {
  transform: translateY(1px);
}

.sofia-chat-back-link svg {
  width: 17px;
  height: 17px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sofia-chat-header-action {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: rgba(20, 32, 45, 0.62);
}

.sofia-chat-header-action svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sofia-chat-context {
  width: fit-content;
  max-width: min(100%, var(--sofia-thread-width));
  margin: 0 0 18px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 999px;
  color: var(--sofia-muted);
  background: rgba(255, 255, 255, 0.54);
  box-shadow:
    0 8px 24px rgba(20, 32, 45, 0.035),
    inset 0 1px 0 rgba(255, 255, 255, 0.82);
  font-size: 12.5px;
  line-height: 1.2;
}

.sofia-chat-context[hidden] {
  display: none !important;
}

.sofia-chat-context strong {
  min-width: 0;
  color: var(--sofia-text);
  font-weight: 560;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sofia-chat-context a,
.sofia-chat-context button {
  border: 0;
  background: transparent;
  color: var(--sofia-teal);
  font: inherit;
  font-weight: 560;
  text-decoration: none;
  cursor: pointer;
}

.sofia-chat-context button {
  width: 22px;
  height: 22px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border-radius: 999px;
}

.sofia-chat-context a:hover,
.sofia-chat-context button:hover,
.sofia-chat-context a:focus-visible,
.sofia-chat-context button:focus-visible {
  background: rgba(31, 127, 155, 0.08);
  outline: none;
}

.sofia-chat-header-actions {
  grid-column: 3;
  justify-self: end;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.sofia-chat-thread-frame,
.sofia-chat-inner {
  width: min(var(--sofia-thread-width), calc(100% - 56px));
  margin-inline: auto;
}

.sofia-chat-thread-frame {
  flex: 1 0 auto;
  padding: 34px 0 178px;
}

.sofia-chat-thread,
.sofia-chat-page .fp-chat-conversation {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 26px;
  padding: 0;
  scroll-behavior: smooth;
}

.sofia-chat-thread.is-open {
  display: flex;
}

.sofia-chat-page .fp-chat-msg {
  position: relative;
  max-width: none;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: var(--sofia-text);
  font-size: 15.5px;
  line-height: 1.68;
  overflow: visible;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  animation: sofia-chat-message-in 220ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.sofia-chat-page .fp-chat-msg--user {
  align-self: flex-end;
  max-width: 68%;
  padding: 12px 16px;
  border-radius: 20px 20px 7px 20px;
  color: #fff;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0)),
    linear-gradient(135deg, #2a9fc0, #1f7f9b);
  box-shadow: 0 10px 24px rgba(31, 127, 155, 0.16);
  line-height: 1.55;
}

.sofia-chat-page .fp-chat-msg--ai {
  align-self: flex-start;
  width: min(var(--sofia-response-width), 100%);
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 14px;
}

.sofia-chat-page .fp-chat-msg--ai::before {
  content: "";
  width: 32px;
  height: 32px;
  margin-top: 2px;
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0)),
    linear-gradient(135deg, #35b4ce, #1f7f9b);
  box-shadow: 0 8px 18px rgba(31, 127, 155, 0.12);
}

.sofia-chat-page .fp-chat-msg--ai .markdown-body {
  min-width: 0;
  max-width: 100%;
  padding: 0;
  background: transparent !important;
  color: rgba(23, 33, 43, 0.73) !important;
  font: inherit;
  font-size: 15.5px;
  line-height: 1.72;
  overflow-x: auto;
}

.sofia-chat-page .fp-chat-msg--ai .markdown-body>*:first-child {
  margin-top: 0 !important;
}

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

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

.sofia-chat-page .fp-chat-msg--ai .markdown-body ul,
.sofia-chat-page .fp-chat-msg--ai .markdown-body ol {
  margin: 10px 0 14px;
  padding-left: 1.18em;
}

.sofia-chat-page .fp-chat-msg--ai .markdown-body li {
  margin: 0 0 7px;
}

.sofia-chat-page .fp-chat-msg--ai .markdown-body li>ul,
.sofia-chat-page .fp-chat-msg--ai .markdown-body li>ol {
  margin-top: 6px;
}

.sofia-chat-page .fp-chat-msg--ai .markdown-body strong {
  color: var(--sofia-text);
  font-weight: 580;
}

.sofia-chat-page .fp-chat-msg--ai .markdown-body h1,
.sofia-chat-page .fp-chat-msg--ai .markdown-body h2,
.sofia-chat-page .fp-chat-msg--ai .markdown-body h3 {
  margin: 18px 0 8px;
  color: var(--sofia-text);
  font-weight: 580;
  letter-spacing: -0.025em;
}

.sofia-chat-page .fp-chat-msg--ai .markdown-body h1 {
  font-size: 22px;
}

.sofia-chat-page .fp-chat-msg--ai .markdown-body h2 {
  font-size: 18px;
}

.sofia-chat-page .fp-chat-msg--ai .markdown-body h3 {
  font-size: 16px;
}

.sofia-chat-page .fp-chat-msg--ai .markdown-body hr {
  display: none;
}

.sofia-chat-page .fp-chat-msg--ai .markdown-body code,
.sofia-chat-page .fp-chat-msg--ai .markdown-body pre {
  border-radius: 12px;
  background: rgba(30, 41, 59, 0.055);
}

.sofia-chat-page .fp-chat-msg--ai .markdown-body details {
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.58);
  box-shadow:
    0 10px 28px rgba(20, 32, 45, 0.035),
    inset 0 1px 0 rgba(255, 255, 255, 0.84);
}

.sofia-chat-page .fp-chat-msg--ai .markdown-body summary {
  color: var(--sofia-teal);
  font-weight: 580;
  cursor: pointer;
}

.sofia-chat-page .fp-chat-msg-actions {
  grid-column: 2;
  justify-self: start;
}

.sofia-chat-page .fp-chat-msg--ai .fp-chat-msg-actions {
  margin-top: 12px;
}

.sofia-chat-page .fp-chat-typing {
  align-self: flex-start;
  margin-left: 50px;
  border: 0;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.66);
  box-shadow:
    0 10px 28px rgba(20, 32, 45, 0.035),
    inset 0 1px 0 rgba(255, 255, 255, 0.86);
}

.sofia-chat-composer-shell {
  position: sticky;
  bottom: 0;
  z-index: 15;
  margin-top: auto;
  pointer-events: none;
}

.sofia-chat-composer-layer {
  padding: 22px 0 26px;
  background:
    linear-gradient(180deg,
      rgba(247, 249, 249, 0),
      rgba(247, 249, 249, 0.92) 30%,
      rgba(247, 249, 249, 0.99));
  pointer-events: none;
}

.sofia-chat-composer-layer .fp-chat-file-bar {
  width: min(var(--sofia-thread-width), calc(100% - 56px));
  margin: 0 auto 10px;
  pointer-events: auto;
}

.sofia-chat-composer {
  width: min(var(--sofia-thread-width), calc(100% - 56px));
  min-height: 72px;
  margin-inline: auto;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 42px auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid rgba(30, 41, 59, 0.1);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow:
    0 18px 46px rgba(20, 32, 45, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(20px);
  pointer-events: auto;
  view-transition-name: sofia-composer;
}

.sofia-chat-composer:focus-within {
  border-color: rgba(31, 127, 155, 0.34);
  box-shadow:
    0 20px 52px rgba(26, 57, 68, 0.1),
    0 0 0 4px rgba(31, 127, 155, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.96);
}

.sofia-chat-composer textarea {
  min-width: 0;
  min-height: 24px;
  max-height: 116px;
  height: 24px;
  padding: 0;
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--sofia-text);
  font: inherit;
  font-size: 15px;
  line-height: 1.55;
  overflow-y: hidden;
  scrollbar-width: thin;
}

.sofia-chat-composer textarea::placeholder {
  color: var(--sofia-soft);
  display: flex;
  align-items: center;
  justify-content: center;
}


.sofia-chat-composer .composer-icon,
.sofia-chat-composer .composer-send {
  flex: 0 0 auto;
}

.sofia-chat-composer .composer-icon {
  width: 42px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  background: rgba(31, 127, 155, 0.075);
  color: var(--sofia-teal);
  cursor: pointer;
  transition:
    background 160ms ease,
    color 160ms ease,
    transform 160ms cubic-bezier(0.22, 1, 0.36, 1);
}

.sofia-chat-composer .composer-icon:hover,
.sofia-chat-composer .composer-icon:focus-visible {
  background: rgba(31, 127, 155, 0.12);
  outline: none;
}

.sofia-chat-composer .composer-icon:active {
  transform: translateY(1px);
}

/* Active (recording) state. speechToText.js adds `.listening` while the STT
   socket is streaming; give the mic a clear on-theme "on" state with a soft
   teal fill and a pulsing halo so the live mic is obvious. (The connecting
   spinner is handled globally via .stt-connecting in style.css.) */
.sofia-chat-composer .composer-mic.listening {
  background: rgba(31, 127, 155, 0.18);
  animation: sofia-mic-pulse 1.5s ease-out infinite;
}

@keyframes sofia-mic-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(31, 127, 155, 0.34);
  }

  70% {
    box-shadow: 0 0 0 9px rgba(31, 127, 155, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(31, 127, 155, 0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .sofia-chat-composer .composer-mic.listening {
    animation: none;
    box-shadow: 0 0 0 4px rgba(31, 127, 155, 0.18);
  }
}

.sofia-chat-composer .composer-icon svg,
.sofia-chat-composer .composer-send svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sofia-chat-composer .composer-send {
  min-width: 92px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, #2a9fc0 0%, #1f7f9b 100%);
  color: #fff;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(31, 127, 155, 0.18);
  transition:
    transform 160ms cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 160ms ease,
    opacity 160ms ease;
}

.sofia-chat-composer .composer-send:not(:disabled):hover,
.sofia-chat-composer .composer-send:not(:disabled):focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 16px 32px rgba(31, 127, 155, 0.22);
  outline: none;
}

.sofia-chat-composer .composer-send:not(:disabled):hover svg {
  transform: translateX(2px);
}

.sofia-chat-composer .composer-send:disabled {
  cursor: default;
  opacity: 0.72;
  background: rgba(31, 127, 155, 0.34);
  box-shadow: none;
}

.sofia-chat-composer .composer-send svg {
  transition: transform 160ms cubic-bezier(0.22, 1, 0.36, 1);
}

/* While Sofia is thinking/streaming the send button becomes a round Stop
   button (frontpage-chat.js sets [data-streaming]). */
.sofia-chat-composer .composer-send .composer-send__stop {
  display: none;
  fill: currentColor;
  stroke: none;
}

.sofia-chat-composer .composer-send[data-streaming] {
  min-width: 44px;
  width: 44px;
  padding: 0;
}

.sofia-chat-composer .composer-send[data-streaming] span,
.sofia-chat-composer .composer-send[data-streaming] svg:not(.composer-send__stop) {
  display: none;
}

.sofia-chat-composer .composer-send[data-streaming] .composer-send__stop {
  display: block;
}

.sofia-chat-composer .composer-send[data-streaming]:not(:disabled):hover svg {
  transform: none;
}

body.fp-chat-arriving .sofia-chat-page {
  animation: sofia-workspace-arrive 300ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

body.fp-chat-handoff-loading .sofia-dashboard-hero {
  opacity: 0.88;
  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;
}

@keyframes sofia-workspace-arrive {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes sofia-chat-message-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1024px) {
  .sb-main:has(> .sofia-chat-page) {
    padding: 0 !important;
  }
}

@media (max-width: 860px) {
  .sofia-chat-page {
    --sofia-thread-width: 100%;
    --sofia-header-width: 100%;
  }

  .sofia-chat-header-inner {
    width: min(100%, calc(100% - 32px));
  }

  .sofia-chat-thread-frame,
  .sofia-chat-inner {
    width: min(100%, calc(100% - 32px));
  }

  .sofia-chat-thread-frame {
    padding-top: 24px;
    padding-bottom: 168px;
  }

  .sofia-chat-page .fp-chat-msg--user {
    max-width: 84%;
  }

  .sofia-chat-page .fp-chat-msg--ai {
    grid-template-columns: 32px minmax(0, 1fr);
    gap: 11px;
  }

  .sofia-chat-page .fp-chat-msg--ai::before {
    width: 29px;
    height: 29px;
  }

  .sofia-chat-composer-layer {
    padding: 18px 0 20px;
  }

  .sofia-chat-composer,
  .sofia-chat-composer-layer .fp-chat-file-bar {
    width: min(100%, calc(100% - 32px));
  }

  .sofia-chat-composer {
    grid-template-columns: 42px minmax(0, 1fr) 42px 46px;
    min-height: 68px;
  }

  .sofia-chat-composer .composer-send {
    min-width: 46px;
    padding: 0;
  }

  .sofia-chat-composer .composer-send span {
    display: none;
  }
}

/* ≤1024px is where the sidebar collapses to the fixed left-edge drawer tab
   (.sb-mobile-menu-toggle). Reserve its footprint so the back link/arrow never
   sits underneath it. box-sizing is explicit so the padding can't push the
   header into horizontal overflow regardless of the global box model. */
@media (max-width: 1024px) {
  .sofia-chat-header-inner {
    box-sizing: border-box;
    padding-left: 44px;
  }
}

@media (max-width: 700px) {
  .sofia-chat-header {
    height: 60px;
    min-height: 60px;
  }

  .sofia-chat-header-inner {
    width: min(100%, calc(100% - 28px));
    grid-template-columns: 42px minmax(0, 1fr) auto;
    gap: 8px;
  }

  .sofia-chat-back-link {
    width: 38px;
    min-height: 38px;
    padding: 0;
  }

  .sofia-chat-back-link span {
    display: none;
  }

  .sofia-chat-header-actions {
    gap: 4px;
  }

  .sofia-chat-header-action {
    width: 36px;
    height: 36px;
  }

  .sofia-chat-header-action svg {
    width: 17px;
    height: 17px;
  }
}

@media (max-width: 560px) {
  .sofia-chat-context {
    max-width: 100%;
    white-space: normal;
  }
}

@media (prefers-reduced-motion: reduce) {

  .sofia-transition-element,
  .sofia-transition-composer,
  .sofia-chat-page,
  .sofia-chat-page .fp-chat-msg,
  body.fp-chat-arriving .sofia-chat-page,
  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;
  }
}

/* ==========================================================================
   Empty-state hero — "Start med Sofia"
   --------------------------------------------------------------------------
   Before the first message the page reads as the dashboard command card: a
   single centred card holding the Sofia mark, the headline and the composer.
   frontpage-chat.js moves [data-sofia-composer-layer] into the card's slot
   while the thread is empty and returns it to the sticky footer shell the
   moment .has-messages lands, so there is only ever ONE composer in the DOM
   and every listener bound at init survives the move.
   ========================================================================== */

/* Hero mode: the chat chrome (back / new chat / history) belongs to an active
   conversation — the card carries its own history trigger instead. */
.sofia-chat-page:not(.has-messages) .sofia-chat-header {
  display: none;
}

/* Widen past the thread measure so the card matches the dashboard hero, and
   drop the sticky-composer bottom padding (the composer lives in the card). */
.sofia-chat-page:not(.has-messages) .sofia-chat-thread-frame {
  width: min(var(--sofia-header-width), calc(100% - 56px));
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 34px 0 40px;
}

.sofia-chat-page.has-messages .sofia-chat-hero {
  display: none;
}

.sofia-chat-hero {
  position: relative;
  width: 100%;
  padding: 46px 36px 42px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 28px;
  background:
    radial-gradient(circle at 7% 0%, rgba(38, 159, 177, 0.1), transparent 32%),
    radial-gradient(circle at 94% 100%, rgba(74, 160, 132, 0.075), transparent 32%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(252, 254, 253, 0.9));
  box-shadow:
    0 18px 48px rgba(20, 32, 45, 0.05),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.sofia-hero-utilities {
  position: absolute;
  top: 26px;
  right: 30px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* .fp-prev-chats-trigger's base styles come from frontpage-chat.css, which
   centres it under the dashboard card; inside the hero it is a corner link. */
.sofia-hero-utilities .fp-prev-chats-trigger {
  margin: 0;
  color: rgba(23, 33, 43, 0.46);
  font-size: 13px;
  font-weight: 520;
  white-space: nowrap;
}

.sofia-hero-utilities .fp-prev-chats-trigger:hover,
.sofia-hero-utilities .fp-prev-chats-trigger:focus-visible {
  color: var(--sofia-teal);
  outline: none;
}

.sofia-hero-header {
  max-width: 620px;
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.sofia-hero-identity {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 0 18px;
}

.sofia-chat-hero .sofia-mark {
  display: block;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  border-radius: 15px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0)),
    linear-gradient(135deg, #35b4ce 0%, #1f7f9b 58%, #257f73 100%);
  box-shadow:
    0 10px 22px rgba(31, 127, 155, 0.14),
    inset 0 1px 0 rgba(255, 255, 255, 0.32);
}

.sofia-chat-hero .sofia-title {
  max-width: 620px;
  margin: 0 auto;
  color: var(--sofia-text);
  font-size: clamp(32px, 3.8vw, 44px);
  line-height: 1.06;
  letter-spacing: -0.05em;
  font-weight: 580;
}

.sofia-chat-hero .sofia-text {
  max-width: 560px;
  margin: 14px auto 0;
  color: var(--sofia-muted);
  font-size: 16px;
  line-height: 1.6;
}

.sofia-hero-composer-slot {
  width: min(868px, 100%);
  margin: 38px auto 0;
}

/* The relocated composer layer sheds the sticky-footer scrim + width clamp. */
.sofia-hero-composer-slot .sofia-chat-composer-layer {
  padding: 0;
  background: none;
}

.sofia-hero-composer-slot .sofia-chat-composer,
.sofia-hero-composer-slot .fp-chat-file-bar {
  width: 100%;
}

/* Two-row composer: the field spans the full width and the controls sit on a
   baseline row beneath it, as on the dashboard hero. */
.sofia-hero-composer-slot .sofia-chat-composer {
  grid-template-columns: 44px minmax(0, 1fr) 42px auto;
  grid-template-areas:
    "input input input input"
    "add spacer mic send";
  column-gap: 10px;
  row-gap: 8px;
  min-height: 0;
  padding: 16px 16px 12px;
  background: #fff;
}

.sofia-hero-composer-slot .sofia-chat-composer textarea,
.sofia-hero-composer-slot .sofia-chat-composer input[type="text"] {
  grid-area: input;
  width: 100%;
  padding: 2px 6px;
}

.sofia-hero-composer-slot .sofia-chat-composer .composer-add {
  grid-area: add;
}

.sofia-hero-composer-slot .sofia-chat-composer .composer-mic {
  grid-area: mic;
  justify-self: end;
}

.sofia-hero-composer-slot .sofia-chat-composer .composer-send {
  grid-area: send;
  justify-self: end;
  min-width: 100px;
}

@media (max-width: 760px) {
  .sofia-chat-page:not(.has-messages) .sofia-chat-thread-frame {
    width: min(100%, calc(100% - 32px));
    padding: 20px 0 28px;
  }

  .sofia-chat-hero {
    padding: 58px 18px 20px;
    border-radius: 22px;
  }

  .sofia-hero-utilities {
    top: 18px;
    right: 18px;
  }

  .sofia-hero-composer-slot {
    margin-top: 20px;
  }

  .sofia-hero-composer-slot .sofia-chat-composer {
    grid-template-columns: 42px minmax(0, 1fr) 42px auto;
    padding: 14px 12px 10px;
  }

  /* The footer composer hides the Send label to save room; inside the hero
     the controls have their own row, so keep the label. */
  .sofia-hero-composer-slot .sofia-chat-composer .composer-send {
    min-width: 96px;
    padding: 0 16px;
  }

  .sofia-hero-composer-slot .sofia-chat-composer .composer-send span {
    display: inline;
  }
}

/* ============ Composer "+" add menu (Sofia chat page) ============
   Built by frontpage-chat.js right after the + button. Shown/hidden via the
   `hidden` attribute (display:none) so the open animation replays each time.
   Radii are concentric on purpose: pill 20px = item 12px + padding 8px. */

.sofia-chat-composer {
  position: relative;
}

.sofia-chat-composer .composer-add[aria-expanded="true"] {
  background: rgba(31, 127, 155, 0.16);
}

.sofia-add-menu {
  position: absolute;
  top: calc(100% + 2px);
  left: 12px;
  z-index: 20;
  width: max-content;
  min-width: 156px;
  display: grid;
  justify-items: stretch;
  gap: 4px;
  padding: 8px;
  box-sizing: border-box;
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow:
    0 10px 24px rgba(0, 0, 0, 0.1),
    0 2px 6px rgba(0, 0, 0, 0.04);
  transform-origin: top left;
  animation: sofiaAddMenuIn 0.14s cubic-bezier(0.2, 0.8, 0.3, 1) both;
}

.sofia-add-menu[hidden] {
  display: none;
}

/* Inside the hero the + button sits in its own row with 16px side padding. */
.sofia-hero-composer-slot .sofia-add-menu {
  left: 16px;
}

/* Once the thread has messages the composer is a sticky footer, so the pill
   opens upward instead of disappearing below the viewport. */
.sofia-chat-page.has-messages .sofia-add-menu {
  top: auto;
  bottom: calc(100% + 2px);
  transform-origin: bottom left;
  animation-name: sofiaAddMenuInUp;
}

.sofia-add-menu__item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: auto;
  min-height: 38px;
  padding: 0 12px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: rgb(23, 32, 51);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.2;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.sofia-add-menu__item:hover {
  color: rgb(22, 140, 164);
  background-color: rgba(22, 140, 164, 0.08);
}

.sofia-add-menu__item:focus-visible {
  outline: 2px solid rgb(22, 140, 164);
  outline-offset: -2px;
  color: rgb(22, 140, 164);
  background-color: rgba(22, 140, 164, 0.08);
}

.sofia-add-menu__icon {
  flex: 0 0 auto;
  display: inline-flex;
  width: 18px;
  height: 18px;
  opacity: 0.75;
}

.sofia-add-menu__icon svg {
  width: 18px;
  height: 18px;
}

@keyframes sofiaAddMenuIn {
  from {
    opacity: 0;
    transform: translateY(-4px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes sofiaAddMenuInUp {
  from {
    opacity: 0;
    transform: translateY(4px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sofia-add-menu {
    animation: none;
  }
}

/* AI disclaimer under the composer. Same wording, keys and look as the
   dashboard composer (frontpage.css), but scoped to the composer layer so it
   travels with the composer between the empty-state hero and the sticky
   footer. The layer itself is pointer-events: none, so the policy link has to
   switch them back on. */
.sofia-chat-composer-layer .sofia-composer__disclaimer {
  width: min(var(--sofia-thread-width), calc(100% - 56px));
  margin: 8px auto 0;
  text-align: center;
  font-size: 11px;
  line-height: 1.4;
  color: rgba(20, 32, 45, 0.55);
  pointer-events: auto;
}

.sofia-chat-composer-layer .sofia-composer__disclaimer a {
  color: inherit;
  font-weight: 700;
  text-decoration: underline;
}

/* In the hero the layer drops its width clamp, so the note follows suit. */
.sofia-hero-composer-slot .sofia-composer__disclaimer {
  width: 100%;
}

@media (max-width: 860px) {
  .sofia-chat-composer-layer .sofia-composer__disclaimer {
    width: min(100%, calc(100% - 32px));
  }
}
