/* The /chat page (In-app chat US-007), built to the US-003 mockup Kevin approved in US-004
   (22-in-app-chat/prototype/chat.css). A page of its own: no dashboard sidebar or top bar; its
   sidebar is Search, New chat and the Chats list. The conversation is today's chat (.agx-thread,
   .agx-me, .agx-ai in homla-agents.css). New classes carry the hc- prefix. One markup for desktop
   and phone: under 820px the sidebar becomes the round 19 v2 drawer. */

/* A page of its own, like the setup steps (#app.is-setup in homla-home-onboarding.css). */
#app.is-chat:not(.hide) { display: block; }
#app.is-chat > .h-side,
#app.is-chat .h-top,
#app.is-chat #mfa-banner,
#app.is-chat #guest-invites-banner { display: none; }
#app.is-chat #main.content { padding: 0; max-width: none; }
#app.is-chat #main.content > #view-chat { max-width: none; }

.hc-app { display: flex; height: 100vh; height: 100dvh; min-height: 560px; overflow: hidden; background: var(--bg-canvas); color: var(--text); }
:where(.hc-app) a { color: inherit; text-decoration: none; }
:where(.hc-app) button { font: inherit; color: inherit; }

/* ---------------------------------------------------------------- Sidebar */
.hc-side { position: relative; width: 264px; flex: none; display: flex; flex-direction: column; padding: 10px 10px 12px; background: var(--bg-hover); border-right: 1px solid var(--line); }
.hc-side__brand { display: flex; align-items: center; height: 40px; padding: 0 10px; margin-bottom: 6px; }
.hc-side__brand img { height: 22px; width: auto; display: block; }
.hc-nav { display: flex; flex-direction: column; gap: 2px; }
.hc-nav__item { display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 10px; border: 0; border-radius: var(--r-lg); background: none; font-size: var(--fs-14); font-weight: 500; width: 100%; text-align: left; cursor: pointer; }
.hc-nav__item:hover { background: color-mix(in srgb, var(--text) 5%, transparent); }
.hc-nav__item[aria-current="page"] { background: color-mix(in srgb, var(--text) 8%, transparent); }
.hc-nav__item .h-i { width: 16px; height: 16px; color: var(--text-2); }
.hc-nav__item .hc-kbd { margin-left: auto; font: 500 var(--fs-11)/1 var(--font-mono); color: var(--text-2); }
.hc-side__label { display: flex; align-items: center; gap: 4px; padding: 20px 10px 6px; font-size: var(--fs-12); font-weight: 500; color: var(--text-2); }
.hc-list { display: flex; flex-direction: column; gap: 1px; min-height: 0; overflow-y: auto; scrollbar-width: none; }
.hc-list::-webkit-scrollbar { display: none; }
.hc-row { position: relative; flex: none; display: flex; align-items: center; gap: 10px; min-height: 34px; padding: 0 26px 0 10px; border-radius: var(--r-lg); font-size: var(--fs-14); }
.hc-row:hover { background: color-mix(in srgb, var(--text) 5%, transparent); }
.hc-row[aria-current="page"] { background: color-mix(in srgb, var(--text) 8%, transparent); }
.hc-row__text { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.hc-row__title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hc-row__meta { display: none; }
.hc-row--chat { padding-left: 42px; }
.hc-side__all { display: block; flex: none; padding: 8px 10px 0 42px; border: 0; background: none; text-align: left; font-size: var(--fs-13); color: var(--text-2); cursor: pointer; }
.hc-side__all:hover { color: var(--text); text-decoration: underline; }
.hc-side__foot { margin-top: auto; padding-top: 10px; }
.hc-user { display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px; border: 0; border-radius: var(--r-lg); background: none; cursor: pointer; text-align: left; }
.hc-user:hover, .hc-app.is-menu .hc-user { background: color-mix(in srgb, var(--text) 6%, transparent); }
.hc-user__text { min-width: 0; display: flex; flex-direction: column; }
.hc-user__name { font-size: var(--fs-13); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hc-user__team { font-size: var(--fs-12); color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hc-user .hc-user__chev { display: none; margin-left: auto; color: var(--text-2); flex: none; }

/* Agent avatar: today's tile, on the page's surface (dark mode too). */
#view-chat .ag-avatar { flex: none; display: inline-grid; place-items: center; border-radius: var(--r-md); background: color-mix(in srgb, var(--ag) 18%, var(--bg-surface)); color: #292929; line-height: 1; overflow: hidden; }
#view-chat .hc-av--homla { background: var(--tint); }
#view-chat .hc-av--homla img { width: 62%; height: 62%; display: block; }

/* Account menu: Appearance, Settings, Sign out */
.hc-menu { position: absolute; left: 10px; bottom: 64px; width: 244px; display: none; z-index: var(--z-drop, 40); }
.hc-app.is-menu .hc-menu { display: block; }
.hc-menu__ws { padding: 8px 8px 6px; display: flex; flex-direction: column; gap: 1px; }
.hc-menu__ws b { font-size: var(--fs-13); font-weight: 500; }
.hc-menu__ws span { font-size: var(--fs-12); color: var(--text-2); }
.hc-menu__theme { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 8px; font-size: var(--fs-13); }
.hc-menu .h-menu__item { width: 100%; }
.hc-catch { position: fixed; inset: 0; z-index: calc(var(--z-drop, 40) - 1); display: none; }
.hc-app.is-menu .hc-catch { display: block; }

/* ------------------------------------------------------------------ Main */
.hc-main { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; }
.hc-top { height: 56px; flex: none; display: flex; align-items: center; gap: 8px; padding: 0 16px; border: 0; }
.hc-top__menu { display: none; }
.hc-top__title { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: var(--fs-14); font-weight: 500; }
.hc-top__title .hc-chip { display: inline-flex; align-items: center; gap: 8px; min-width: 0; height: 32px; padding: 0 12px 0 5px; border: 1px solid var(--line); border-radius: var(--r-pill); background: var(--bg-surface); }
.hc-top__right { margin-left: auto; display: flex; gap: 4px; }

/* New chat: logo and composer centred (Grok web) */
.hc-hero { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 0 24px 96px; }
.hc-hero__mark { margin-bottom: 28px; }
.hc-hero__mark img { height: 34px; width: auto; display: block; }
.hc-hero__dock { width: 100%; max-width: 720px; display: flex; flex-direction: column; }
.hc-chips { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }
.hc-chips .h-btn { border-radius: var(--r-pill); height: 32px; padding: 0 14px; font-size: var(--fs-13); font-weight: 400; color: var(--text); }
.hc-chips .h-btn .h-i { color: var(--text-2); }
.hc-none { margin: 0; text-align: center; font-size: var(--fs-14); color: var(--text-2); }

/* Composer: today's .agx-composer box */
.hc-composer { position: relative; display: flex; flex-direction: column; gap: 8px; padding: 12px 10px 10px 16px; border: 1px solid var(--line-strong); border-radius: var(--r-xl); background: var(--bg-surface); box-shadow: var(--shadow-1); }
#view-chat .hc-composer textarea { display: block; width: 100%; min-height: 26px; max-height: 192px; margin: 0; border: 0; border-radius: 0; box-shadow: none; outline: 0; resize: none; background: transparent; color: var(--text); font: 400 var(--fs-15)/1.5 var(--font-sans); padding: 2px 0 0; }
.hc-composer textarea::placeholder { color: var(--text-2); }
.hc-composer__bar { display: flex; align-items: center; gap: 8px; min-height: 28px; }
.hc-composer__bar .h-btn--primary { margin-left: auto; }
.hc-composer .h-slash { position: absolute; left: 0; right: 0; bottom: calc(100% + 8px); margin: 0; }
.hc-hero .hc-composer .h-slash { bottom: auto; top: calc(100% + 8px); }

/* Who a new chat goes to */
.hc-pick { position: relative; min-width: 0; margin-left: -6px; }
.hc-pick__btn { max-width: 260px; gap: 6px; padding: 0 8px 0 4px; border-radius: var(--r-pill); color: var(--text); font-weight: 400; }
.hc-pick__btn .h-i { color: var(--text-2); flex: none; }
.hc-pick__menu { position: absolute; left: 0; top: calc(100% + 6px); min-width: 220px; max-height: 280px; overflow-y: auto; z-index: var(--z-drop, 40); }
.hc-pick__menu .h-menu__item { width: 100%; gap: 10px; }

/* Conversation */
.hc-scroll { flex: 1; min-height: 0; overflow-y: auto; }
.hc-scroll .agx-thread { padding-top: var(--s-4); }
.hc-dock { flex: none; width: 100%; max-width: 768px; margin: 0 auto; padding: 0 var(--s-6) var(--s-5); }
.hc-dock .agx-paused { margin: 0; }
.hc-intro { display: flex; flex-direction: column; align-items: center; text-align: center; padding-top: 32px; }
.hc-intro .ag-avatar { margin-bottom: 12px; border-radius: var(--r-lg); }
.agx-ai__body .h-md ul { margin: 0; padding-left: 20px; }
.agx-ai__body .h-md li + li { margin-top: 4px; }

/* Cards in the chat (US-008): today's .h-approval look, trimmed to Do it / Don't; one line once decided */
.hc-card { max-width: 600px; }
.agx-ai__body .hc-card { max-width: 600px; }
.hc-card .h-approval__head { align-items: flex-start; }
.hc-card .h-approval__meta { font-size: var(--fs-12); }
.hc-card__quote { font-size: var(--fs-14); line-height: 1.5; padding-left: 12px; border-left: 2px solid var(--line-strong); overflow-wrap: anywhere; }
.hc-card .h-approval__actions .hc-see { margin-left: auto; color: var(--text-2); }
.hc-card .h-approval__actions .hc-see:hover { color: var(--text); }
.hc-card__wait { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-13); color: var(--text-2); }
.hc-card.h-approval--decided { width: fit-content; min-width: 300px; gap: 12px; background: transparent; box-shadow: none; border-color: var(--line-strong); padding: 8px 12px 8px 8px; }
.hc-card.h-approval--decided b { font-weight: 500; font-size: var(--fs-14); min-width: 0; overflow-wrap: anywhere; }
.hc-ok { margin-left: auto; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--tint); color: var(--on-tint); flex: none; }
.hc-ok .h-i { width: 12px; height: 12px; }
.hc-ok--skip { background: var(--bg-sunken); color: var(--text-2); }
.hc-ok--bad { background: var(--danger-tint, var(--bg-sunken)); color: var(--danger, var(--text-2)); }

/* Search: Grok's centred list; a bottom sheet on the phone */
.hc-scrim { position: fixed; inset: 0; background: var(--overlay); z-index: var(--z-modal, 60); }
.hc-modal { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(540px, calc(100vw - 32px)); max-height: calc(100dvh - 80px); overflow: auto; z-index: calc(var(--z-modal, 60) + 1); padding: 20px 20px 12px; border: 1px solid var(--line); border-radius: var(--r-xl); background: var(--bg-surface); box-shadow: var(--shadow-3); }
.hc-modal__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.hc-modal__head h2 { margin: 0; font-size: var(--fs-17); font-weight: 500; letter-spacing: var(--track-title); }
.hc-modal__search { display: flex; align-items: center; gap: 8px; height: 38px; margin: 16px 0 4px; padding: 0 12px; border: 1px solid var(--line-control); border-radius: var(--r-md); font-size: var(--fs-14); color: var(--text-2); cursor: text; }
.hc-modal__search:focus-within { border-color: var(--brand); }
.hc-modal__search .h-i { width: 16px; height: 16px; flex: none; }
#view-chat .hc-modal__search input { flex: 1; min-width: 0; height: 100%; min-height: 0; border: 0; border-radius: 0; box-shadow: none; outline: 0; background: transparent; color: var(--text); font: inherit; padding: 0; }
.hc-modal__search input::placeholder { color: var(--text-2); }
.hc-modal__search input::-webkit-search-cancel-button { display: none; }
.hc-modal__label { padding: 14px 4px 4px; font: 500 var(--fs-11)/1.3 var(--font-mono); letter-spacing: var(--track-mono); text-transform: uppercase; color: var(--text-2); }
.hc-modal__empty { margin: 0; padding: 12px 4px; font-size: var(--fs-14); color: var(--text-2); }
.hc-mrow { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 8px 4px; border-radius: var(--r-md); }
.hc-mrow + .hc-mrow { border-top: 1px solid var(--line); }
a.hc-mrow:hover { background: var(--bg-hover); }
.hc-mrow__t { flex: 1; min-width: 0; }
.hc-mrow__t b { display: block; font-size: var(--fs-14); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hc-mrow__t span { display: block; font-size: var(--fs-12); color: var(--text-2); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hc-tile { width: 32px; height: 32px; flex: none; display: grid; place-items: center; border-radius: var(--r-md); background: var(--bg-sunken); color: var(--text-2); }
.hc-tile .h-i { width: 16px; height: 16px; }
.hc-grab { display: none; }

/* --------------------------------------------- Phone: round 19 v2 drawer */
.hc-drawer-scrim { display: none; }
@media (max-width: 820px) {
  .hc-card.h-approval--decided { min-width: 0; width: 100%; }
  .hc-card .h-approval__actions .hc-see { margin-left: 0; }
  .hc-side { position: fixed; top: 0; bottom: 0; left: 0; width: min(340px, 88vw); z-index: var(--z-drawer, 50); transform: translateX(-102%); transition: transform var(--dur-3) var(--ease-out); background: var(--bg-canvas); border-right: 0; padding: 12px 8px 16px; }
  .hc-app.is-drawer .hc-side { transform: none; box-shadow: var(--shadow-3); }
  .hc-drawer-scrim { position: fixed; inset: 0; background: var(--overlay); z-index: calc(var(--z-drawer, 50) - 1); }
  .hc-app.is-drawer .hc-drawer-scrim { display: block; }
  .hc-side__brand { display: none; }
  .hc-side__foot { order: -1; margin: 0 0 4px; padding: 0; }
  .hc-user { padding: 8px 10px; }
  .hc-user .h-avatar { --_s: 38px; }
  .hc-user__name { font-size: var(--fs-15); }
  .hc-user__team { font-size: var(--fs-13); }
  .hc-user .hc-user__chev { display: block; }
  .hc-side__label { padding: 16px 12px 6px; font-size: var(--fs-13); }
  .hc-list { flex: 1; }
  .hc-row { min-height: 54px; padding: 6px 12px; gap: 12px; }
  .hc-row--chat { padding-left: 12px; }
  .hc-row__title { font-size: var(--fs-15); }
  .hc-row__meta { display: block; font-size: var(--fs-12); color: var(--text-2); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .hc-side__all { display: none; }
  .hc-nav { order: 99; flex-direction: row; gap: 8px; padding: 10px 4px 0; }
  .hc-nav__item { height: 44px; border-radius: var(--r-pill); background: var(--bg-surface); border: 1px solid var(--line); }
  .hc-nav__item:first-child { flex: 1; color: var(--text-2); font-weight: 400; }
  .hc-nav__item:last-child { width: 44px; flex: none; padding: 0; justify-content: center; }
  .hc-nav__item:last-child span { display: none; }
  .hc-nav__item[aria-current="page"] { background: var(--bg-surface); }
  .hc-nav__item .hc-kbd { display: none; }
  .hc-menu { top: 64px; bottom: auto; left: 8px; right: 8px; width: auto; max-width: none; }

  .hc-top { padding: 0 8px; justify-content: space-between; }
  .hc-top__menu { display: inline-flex; }
  .hc-top__title { position: absolute; left: 56px; right: 56px; justify-content: center; }
  .hc-top__title .hc-chip { border: 0; background: none; padding: 0; }
  .hc-top__right { margin-left: 0; }

  .hc-hero { justify-content: space-between; padding: 0 12px 12px; }
  .hc-hero__mark { flex: 1; display: grid; place-items: center; margin: 0; opacity: .35; }
  .hc-hero__mark img { height: 28px; }
  .hc-hero__dock { max-width: none; }
  .hc-chips { order: -1; justify-content: flex-start; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -12px 10px; padding: 0 12px; }
  .hc-chips::-webkit-scrollbar { display: none; }
  .hc-chips .h-btn { flex: none; }
  .hc-hero .hc-composer .h-slash { top: auto; bottom: calc(100% + 8px); }
  .hc-pick__menu { top: auto; bottom: calc(100% + 6px); }
  .hc-dock { padding: 0 var(--s-3) var(--s-3); }
  .hc-scroll .agx-thread { padding: var(--s-3) var(--s-4) var(--s-4); gap: var(--s-5); }
  .hc-scroll .agx-me { max-width: 88%; }
  .hc-scroll .agx-ai__body { grid-column: 1 / -1; }

  .hc-modal { top: auto; bottom: 0; left: 0; transform: none; width: 100%; max-height: 88dvh; border-radius: 20px 20px 0 0; padding: 8px 16px 24px; }
  .hc-grab { display: block; width: 38px; height: 5px; border-radius: 3px; background: var(--line-strong); margin: 0 auto 10px; }
}

/* Light/dark logo swap everywhere on the page (the DS scopes it to known blocks) */
.hc-app .h-logo-dark { display: none; }
:root[data-theme="dark"] .hc-app .h-logo-dark { display: block; }
:root[data-theme="dark"] .hc-app .h-logo-light { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .hc-app .h-logo-dark { display: block; }
  :root:not([data-theme="light"]) .hc-app .h-logo-light { display: none; }
}

/* "See in admin" from the chat: that item outlined on Approvals (/agents/approvals?focus=<id>) */
.hc-focus { outline: 2px solid var(--brand); outline-offset: 4px; border-radius: var(--r-lg); }

/* Dashboard sidebar: "Back to chat" pill at the top (In-app chat US-009, admin copies in the US-003 mockup) */
.h-side .h-side__back { margin: 2px 0 10px; border: 1px solid var(--line-strong); border-radius: var(--r-pill); width: fit-content; padding-right: 14px; }
@media (max-width: 820px) { .h-side .h-side__back { margin: 4px 16px 10px; } }
