/* ════════════════════════════════════════════════════════════════════
   station-chat.css — MIRROR of the @orbit/ui design-system chat preview
   (preview/component-chat.html). Classes + values copied verbatim:
   primitives (.btn / .btn-wrap / .icon-container / .field / .main-input),
   .chat-window / .sidebar / .tab-bar / .search-row / .left-wrap /
   .thread-row / .right-wrap / .chat-head / .pinned-banner / .chat-viewport /
   .messages-pane / .msg-card / .card-header / .left-stack / .avatar-box /
   .pill-wrap / .card-body / .card-text / .reactions-footer / .add-reaction /
   .typing / .composer-wrap / .slash-menu / .data-picker / .composer-chat.
   ════════════════════════════════════════════════════════════════════ */

/* ── chat buttons now DERIVE from the shared .btn (orbit-primitives.css);
   only chat deltas remain: centered icon-only layout + always-visible glyph
   (the shared .btn hides its icon until hover — chat needs it shown). ── */
.station-chat .btn-wrap { display: inline-flex; }
.station-chat .btn { justify-content: center; gap: 8px; padding: 0; font-size: 13px; }
.station-chat .btn:hover { background: var(--2); }
.station-chat .btn .icon-container { transform: none; opacity: 1; color: var(--80); }
.station-chat .btn .icon-container [data-orbit] { width: 18px; height: 18px; }
.station-chat .field { position: relative; display: flex; align-items: center; width: 100%; box-sizing: border-box; height: 44px; padding: 0 6px 0 16px; background: var(--2); border: 1px solid transparent; border-radius: 999px; backdrop-filter: blur(3px); transition: border-color .2s ease; }
.station-chat .field:focus-within { border-color: var(--10); }
.station-chat .field .input-title { display: none; }
.station-chat .field .main-input { flex: 1; min-width: 0; background: transparent; border: none; outline: none; color: var(--100); font-family: var(--f-sans); font-weight: 200; font-size: 14px; }
.station-chat .field .main-input::placeholder { color: var(--40); }
.station-chat .field .button-container { display: inline-flex; }
.station-chat .field .trail-btn { width: 32px; height: 32px; flex: 0 0 32px; display: inline-grid; place-items: center; border: none; border-radius: 50%; background: var(--5); color: var(--80); cursor: pointer; }
.station-chat .field .trail-btn:hover { background: var(--100); color: var(--inv-100); }
.station-chat .field .trail-btn [data-orbit] { width: 15px; height: 15px; }

/* ── window shell ── */
.chat-window { display: grid; grid-template-columns: 320px 1fr; background: var(--inv-100); overflow: hidden; }
.chat-window .sidebar { background: var(--inv-100); border-right: 1px solid var(--5); display: flex; flex-direction: column; overflow: hidden; min-height: 0; }
.chat-window .tab-bar { display: flex; align-items: center; gap: 4px; padding: 10px 12px 6px; border-bottom: 1px solid var(--5); }
.chat-window .tab-bar .tab-group { display: inline-flex; gap: 4px; flex: 1; }
.chat-window .tab-bar .btn-wrap { width: 32px; height: 32px; }
.chat-window .tab-bar .btn { padding: 0; }
.chat-window .tab-bar .btn .icon-container { color: var(--60); }
.chat-window .tab-bar .btn.active .icon-container { color: var(--100); }
.chat-window .tab-bar .tab-item.active .btn { background: var(--5); }
.chat-window .tab-bar .tab-item.has-unread .btn::after { content: ""; position: absolute; top: 2px; right: 2px; width: 5px; height: 5px; border-radius: 50%; background: #fff; box-shadow: 0 0 5px rgba(255,255,255,.95); }
.chat-window .search-row { display: flex; align-items: center; gap: 6px; padding: 8px 12px; }
.chat-window .search-row .search-wrap { flex: 1; min-width: 0; }
.chat-window .search-row .field { height: 40px; }
.chat-window .left-wrap { flex: 1; overflow-y: auto; padding: 8px 8px 12px; min-height: 0; }
.chat-window .thread-list { display: flex; flex-direction: column; gap: 2px; }
.chat-window .thread-row { width: 100%; }
.chat-window .thread-row .btn-wrap { width: 100%; height: auto; }
.chat-window .thread-row .btn { padding: 8px 12px; border-radius: 12px; justify-content: flex-start; gap: 10px; display: flex; align-items: center; text-align: left; background: transparent; }
.chat-window .thread-row .btn:hover { background: var(--2); }
.chat-window .thread-row .btn.active { background: var(--inv-100); box-shadow: 0 4px 12px -2px rgba(0,0,0,.25); }
.chat-window .thread-row .btn.unread { background: var(--100); }
.chat-window .thread-row .thread-icon { width: 36px; height: 36px; flex: 0 0 36px; border-radius: 10px; display: grid; place-items: center; background: var(--5); color: var(--80); overflow: hidden; }
.chat-window .thread-row .btn.active .thread-icon, .chat-window .thread-row .btn.unread .thread-icon { background: var(--inv-80); color: var(--100); }
.chat-window .thread-row .thread-icon [data-orbit] { width: 18px; height: 18px; }
.chat-window .thread-row .thread-icon img { width: 100%; height: 100%; object-fit: cover; }
.chat-window .thread-row .thread-texts { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.chat-window .thread-row .thread-title { margin: 0; font-family: var(--f-sans); font-size: 13px; font-weight: 500; color: var(--100); line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-window .thread-row .btn.unread .thread-title { color: var(--inv-100); }
.chat-window .thread-row .thread-sub { margin: 0; font-family: var(--f-sans); font-size: 11px; color: var(--60); line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-style: italic; }
.chat-window .thread-row .btn.unread .thread-sub { color: rgba(0,0,0,.55); font-style: normal; }
.chat-window .empty-note { padding: 14px 10px; color: var(--40); font-size: 12px; }

/* ── main window ── */
.chat-window .right-wrap { display: flex; flex-direction: column; overflow: hidden; background: var(--inv-100); min-width: 0; min-height: 0; }
.chat-window .chat-head { height: 64px; flex: 0 0 64px; padding: 0 12px 0 14px; display: flex; align-items: center; gap: 14px; border-bottom: 1px solid var(--5); background: linear-gradient(to bottom, rgba(0,0,0,.6), rgba(0,0,0,.3)); backdrop-filter: blur(20px); }
.chat-window .chat-head .back { display: none; }
.chat-window .chat-head .title-zone { flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0; }
.chat-window .chat-head .head-avi { width: 36px; height: 36px; border-radius: 50%; background: var(--5); overflow: hidden; display: grid; place-items: center; cursor: pointer; flex: 0 0 36px; color: var(--80); }
.chat-window .chat-head .head-avi.project { border-radius: 10px; }
.chat-window .chat-head .head-avi [data-orbit] { width: 20px; height: 20px; }
.chat-window .chat-head .head-avi img { width: 100%; height: 100%; object-fit: cover; }
.chat-window .chat-head .head-text { flex: 1; min-width: 0; }
.chat-window .chat-head h3.thread-title { margin: 0; font-family: "Lexend", var(--f-sans); font-size: clamp(16px, 3vw, 22px); font-weight: 180; line-height: 1.4; color: var(--100); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-window .chat-head .actions-zone { display: inline-flex; align-items: center; gap: 4px; }
.chat-window .chat-head .actions-zone .btn-wrap { width: 36px; height: 36px; }
.chat-window .chat-head .actions-zone .btn { padding: 0; }
.chat-window .chat-head .actions-zone .btn .icon-container { color: var(--80); }
.chat-window .chat-head .actions-zone .btn:hover .icon-container { color: var(--100); }
.chat-window .pinned-banner { background: var(--2); border-bottom: 1px solid var(--5); padding: 8px 18px; font-family: "Lexend", var(--f-sans); font-size: 12px; color: var(--60); display: flex; align-items: center; gap: 8px; }
.chat-window .pinned-banner [data-orbit] { width: 14px; height: 14px; }
.chat-window .chat-viewport { flex: 1; overflow: hidden; display: flex; min-height: 0; }
.chat-window .messages-pane { flex: 1; overflow-y: auto; padding: 18px 18px 8px; display: flex; flex-direction: column; gap: 14px; min-height: 0; }
.chat-window .cw-empty { flex: 1; display: grid; place-items: center; color: var(--40); }

/* ── ChatMessage ── */
.msg-row { display: flex; flex-direction: column; width: 100%; }
.msg-row.mine { align-items: flex-end; }
.msg-row.grouped { margin-top: -8px; }
.msg-card { position: relative; max-width: 85%; width: max-content; min-width: 220px; border-radius: 18px; background: var(--2); border: 1px solid var(--5); overflow: visible; }
.msg-row.mine .msg-card { background: var(--5); border-color: var(--10); }
.msg-row.system .msg-card { background: transparent; border: 1px dashed var(--10); font-style: italic; color: var(--60); }
.msg-card.pinned { border-color: var(--accent); }
.msg-card .card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px 6px; }
.msg-card .left-stack { display: flex; align-items: center; gap: 8px; min-width: 0; }
.msg-card .avatar-box { width: 28px; height: 28px; border-radius: 50%; background: var(--5); color: var(--80); display: grid; place-items: center; overflow: hidden; font-family: "Lexend", var(--f-sans); font-weight: 500; font-size: 11px; flex: 0 0 28px; }
.msg-card .avatar-box img { width: 100%; height: 100%; object-fit: cover; }
.msg-card .avatar-box .ob-avatar { width: 28px; height: 28px; }
.msg-card .pill-wrap { background: var(--4); padding: 0 8px; border-radius: 10px; height: 20px; display: flex; align-items: center; min-width: 0; }
.msg-card .pill-wrap .pill-text { font-size: 11px; font-weight: 500; letter-spacing: .2px; color: var(--60); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-card .left-stack .time { font-size: 11px; color: var(--40); margin-left: auto; padding-left: 8px; }
.msg-card .card-body { padding: 2px 14px 12px; }
.msg-card .card-body.no-head { padding-top: 10px; }
.msg-card .card-text { margin: 0; font-family: "Lexend", var(--f-sans); line-height: 1.5; font-weight: 180; font-size: clamp(14px, 3vw, 16px); letter-spacing: .16px; color: var(--100); word-wrap: break-word; white-space: pre-wrap; }
.msg-card .card-text code { font-family: var(--f-sans); font-size: 12px; background: var(--5); border-radius: 4px; padding: 1px 5px; }
.msg-card .card-text .mention-pip { color: var(--accent); }
.msg-card .att-img { display: block; max-width: 240px; border-radius: 12px; margin: 6px 14px 10px; }
/* AstraThinking */
.msg-card .astra-thinking-wrapper { margin: 2px 14px 8px; border-left: 2px solid var(--accent); padding-left: 6px; }
.msg-card .astra-thinking-wrapper .ath-head { display: inline-flex; align-items: center; gap: 6px; font-size: 10px; font-weight: 500; letter-spacing: 1px; text-transform: uppercase; color: var(--40); cursor: pointer; padding: 3px 0; }
.msg-card .astra-thinking-wrapper .ath-head [data-orbit] { width: 12px; height: 12px; }
.msg-card .astra-thinking-wrapper .ath-head .chev { transition: transform .18s; }
.msg-card .astra-thinking-wrapper.open .ath-head .chev { transform: rotate(90deg); }
.msg-card .astra-thinking-wrapper .thinking-content { display: flex; flex-direction: column; gap: 2px; font-size: 12px; line-height: 1.6; color: var(--60); white-space: pre-wrap; word-break: break-word; max-height: 36px; overflow: hidden; padding: 4px 0; }
.msg-card .astra-thinking-wrapper.open .thinking-content { max-height: 300px; overflow-y: auto; }
.msg-card .astra-thinking-wrapper .thinking-line { display: block; color: var(--40); font-size: 12px; line-height: 1.5; margin: 0; }
.msg-card .astra-thinking-wrapper .thinking-line.streaming { color: var(--100); }
.msg-card .astra-thinking-wrapper .blinking-cursor { display: inline-block; font-weight: 900; color: var(--accent); animation: ath-blink .8s steps(2, start) infinite; }
@keyframes ath-blink { to { visibility: hidden; } }
/* hover add-reaction */
.msg-card .add-reaction { position: absolute; bottom: 8px; left: 10px; z-index: 5; opacity: 0; transition: opacity .2s ease, transform .2s ease; transform: translateY(-2px); pointer-events: none; }
.msg-card:hover .add-reaction { opacity: 1; transform: translateY(0); pointer-events: auto; }
.msg-card .add-reaction .btn-wrap { width: 28px; height: 28px; }
.msg-card .add-reaction .btn { width: 28px; height: 28px; padding: 0; background: transparent; border-radius: 50%; }
.msg-card .add-reaction .btn:hover { background: var(--5); }
.msg-card .add-reaction .btn .icon-container { color: var(--60); }
.msg-card .add-reaction .btn:hover .icon-container { color: var(--100); }
.msg-card .add-reaction .btn .icon-container [data-orbit] { width: 16px; height: 16px; }
.msg-card .reactions-footer { padding: 0 12px 10px; }
.msg-card .reactions-list { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.msg-card .reaction-pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; background: var(--2); border: 1px solid var(--5); border-radius: 999px; color: var(--80); cursor: pointer; font-family: "Lexend", var(--f-sans); font-size: 12px; }
.msg-card .reaction-pill.active { background: var(--5); border-color: var(--40); color: var(--100); }
.msg-card .reaction-pill .count { color: var(--40); }

/* TypingDots */
.typing { display: flex; align-items: center; color: var(--60); margin-left: 24px; height: 24px; }
.typing .dots { display: inline-flex; gap: 4px; margin-right: 8px; }
.typing .dots .dot { width: 3px; height: 3px; border-radius: 50%; background: var(--60); animation: typing-dot 1s infinite ease-in-out; }
.typing .dots .dot:nth-child(2) { animation-delay: .15s; }
.typing .dots .dot:nth-child(3) { animation-delay: .3s; }
.typing p { margin: 0; font-size: 11px; font-family: "Lexend", var(--f-sans); }
@keyframes typing-dot { 0%, 80%, 100% { opacity: .2; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-2px); } }

/* ── composer + data-picker ── */
.composer-wrap { display: flex; flex-direction: column; gap: 8px; padding: 12px; position: relative; }
.composer-wrap .typing-floating { position: absolute; top: -14px; left: 12px; }
.slash-menu { background: var(--inv-80); border: 1px solid var(--5); border-radius: var(--r-md, 12px); backdrop-filter: blur(8px); padding: 6px; display: flex; flex-direction: column; gap: 2px; min-width: 260px; }
.slash-menu[hidden] { display: none; }
.slash-menu .slash-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: var(--r-sm, 8px); background: transparent; border: none; color: var(--80); cursor: pointer; font-family: var(--f-sans); font-weight: 180; font-size: 13px; text-align: left; }
.slash-menu .slash-row:hover, .slash-menu .slash-row.active { background: var(--5); color: var(--100); }
.slash-menu .slash-row [data-orbit] { width: 16px; height: 16px; color: var(--60); }
.slash-menu .slash-row:hover [data-orbit], .slash-menu .slash-row.active [data-orbit] { color: var(--100); }
.slash-menu .slash-row .desc { margin-left: auto; font-family: var(--f-sans); font-size: 10px; color: var(--40); }
.data-picker { background: var(--inv-80); border: 1px solid var(--5); border-radius: var(--r-md, 12px); backdrop-filter: blur(8px); overflow: hidden; display: none; flex-direction: column; max-height: 300px; }
.composer-wrap.with-picker .data-picker { display: flex; }
.data-picker .tabs { display: flex; gap: 4px; padding: 8px 8px 0; border-bottom: 1px solid var(--5); }
.data-picker .tabs .tab { padding: 4px 12px; height: 28px; border: none; background: transparent; color: var(--60); font-family: var(--f-sans); font-size: 12px; cursor: pointer; border-radius: 8px; }
.data-picker .tabs .tab.active { color: var(--100); background: var(--5); }
.data-picker .tabs .tab [data-orbit] { width: 14px; height: 14px; vertical-align: -2px; }
.data-picker .body { flex: 1; overflow-y: auto; padding: 10px; }
.data-picker .grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.data-picker .grid.gifs { grid-template-columns: repeat(4, 1fr); }
.data-picker .grid.commands { grid-template-columns: 1fr 1fr; gap: 4px; }
.data-picker .grid .tile { width: 100%; aspect-ratio: 1; border: 1px solid var(--5); background: var(--2); border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; overflow: hidden; transition: background var(--dur-base, .18s) ease, border-color .18s ease; }
.data-picker .grid .tile:hover { background: var(--5); border-color: var(--10); }
.data-picker .grid.emotes .tile { font-size: 20px; background: var(--inv-100); border-color: var(--10); }
.data-picker .grid.gifs .tile { aspect-ratio: 4/3; }
.data-picker .grid.gifs .tile img { width: 100%; height: 100%; object-fit: cover; }
.data-picker .grid .tile [data-orbit] { width: 20px; height: 20px; color: var(--80); }
.data-picker .grid.commands .cmd { aspect-ratio: unset; padding: 8px 12px; text-align: left; display: flex; align-items: center; gap: 10px; font-family: "Lexend", var(--f-sans); font-size: 13px; font-weight: 180; color: var(--80); background: transparent; border: none; cursor: pointer; border-radius: 8px; }
.data-picker .grid.commands .cmd:hover { background: var(--5); color: var(--100); }
.data-picker .grid.commands .cmd [data-orbit] { width: 16px; height: 16px; color: var(--60); }
.data-picker .grid.commands .cmd .desc { margin-left: auto; font-family: var(--f-sans); font-size: 10px; color: var(--40); }
.composer-chat { display: flex; align-items: center; gap: 8px; padding: 6px; border-radius: 18px; background: var(--2); border: 1px solid var(--5); backdrop-filter: blur(12px); }
.composer-chat .left, .composer-chat .right { display: inline-flex; align-items: center; gap: 4px; }
.composer-chat .center { flex: 1; min-width: 0; }
.composer-chat .left .btn-wrap, .composer-chat .right .btn-wrap { width: 36px; height: 36px; }
.composer-chat .left .btn, .composer-chat .right .btn { padding: 0; border-radius: 50%; }
.composer-chat .left .btn.active { background: var(--5); }
.composer-chat .left .btn.active .icon-container { color: var(--100); }
.composer-chat .center .field { background: transparent; border: none; height: 40px; padding: 0 4px; }
.composer-chat .voice-strip { display: flex; align-items: center; gap: 8px; padding: 4px 12px; border-radius: 16px; background: var(--4); border: 1px solid var(--10); flex: 1; }
.composer-chat .voice-dot { width: 10px; height: 10px; border-radius: 50%; background: #6b6b6b; animation: voice-pulse 1.2s ease-in-out infinite; }
@keyframes voice-pulse { 0%, 100% { opacity: .95; transform: scale(1); } 50% { opacity: .45; transform: scale(.7); } }
.composer-chat .voice-elapsed { font-family: var(--f-sans); font-size: 12px; color: var(--100); min-width: 38px; }
.composer-chat .voice-status { font-size: 11px; color: var(--60); flex: 1; }
.composer-chat .voice-bars { display: flex; align-items: center; gap: 2px; height: 18px; }
.composer-chat .voice-bars span { width: 2px; background: var(--60); border-radius: 1px; }
.composer-chat .voice-actions { display: inline-flex; gap: 2px; }

/* ════ ChatLite (visitor reduced chat) — reuses .msg-card chrome ════ */
.chat-lite { display: flex; flex-direction: column; gap: 8px; width: 100%; height: 100%; min-height: 0; }
.chat-lite .cl-feed { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 4px 2px; }
.chat-lite .cl-empty { padding: 12px 8px; text-align: center; color: var(--60); }
.chat-lite .cl-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.chat-lite .msg-row.grouped { margin-top: 0; }
.chat-lite .cl-composer { flex: 0 0 auto; margin-top: auto; width: 100%; }
.chat-lite .composer-wrap { padding: 0; }
/* compact MsgCard in the 380px widget */
.chat-lite .msg-card { min-width: 0; max-width: 100%; border-radius: 14px; }
.chat-lite .card-header { padding: 7px 10px 3px; }
.chat-lite .card-text { font-size: 13px; }
.chat-lite .add-reaction, .chat-lite .reactions-footer { display: none; }
.chat-lite .card-body { padding: 0 10px 8px; }

/* visitor widget host — re-assert fixed size (global .chat-lite 100% would
   make this position:fixed box fill the viewport) */
.st-chat-widget.chat-lite { display: none; box-sizing: border-box; width: min(380px, calc(100vw - 32px)); height: min(520px, calc(100vh - 120px)); padding: 14px; gap: 10px; overflow: hidden; }
.st-chat-widget.chat-lite.open { display: flex; }

/* ════ floating dropdown + docked sidebar hosts ════ */
.chat-window.floating { position: fixed; width: min(1080px, calc(100vw - 24px)); height: min(820px, calc(100vh - 64px)); border: 1px solid var(--10); border-radius: var(--r-lg, 16px); box-shadow: 0 24px 64px rgba(0,0,0,.6); display: none; }
.chat-window.floating.open { display: grid; }
/* docked into the MenuOverlay #ov-chat sidebar — single column */
.chat-window.docked { width: 100%; height: 100%; grid-template-columns: 1fr; border: none; border-radius: 0; box-shadow: none; position: relative; }
.chat-window.docked .resize-handle.w { position: absolute; left: -4px; top: 0; bottom: 0; width: 8px; cursor: ew-resize; z-index: 6; }
.chat-window.docked .resize-handle.w:hover { background: var(--10); }
.chat-window.docked .sidebar { width: 100%; border-right: none; }
.chat-window.docked.show-thread .sidebar { display: none; }
.chat-window.docked:not(.show-thread) .right-wrap { display: none; }
.chat-window.docked .chat-head .back { display: inline-flex; }
/* responsive: once the docked pane is dragged wide enough (≥640px, set by a
   ResizeObserver → `.wide`), reveal BOTH panes — threads left of the chat —
   instead of the single-column mobile toggle. Narrower → collapses back. */
.chat-window.docked.wide { grid-template-columns: 300px 1fr; }
.chat-window.docked.wide .sidebar { display: flex !important; border-right: 1px solid var(--5); }
.chat-window.docked.wide .right-wrap { display: flex !important; }
.chat-window.docked.wide .chat-head .back { display: none !important; }
/* narrow floating → single column too */
@media (max-width: 720px) {
  .chat-window.floating { grid-template-columns: 1fr; }
  .chat-window.floating.show-thread .sidebar { display: none; }
  .chat-window.floating:not(.show-thread) .right-wrap { display: none; }
  .chat-window.floating .chat-head .back { display: inline-flex; }
}

/* MenuOverlay 2-column layout when the chat sidebar is open */
.st-ov-main .st-ov-tab { grid-column: 1; }
.st-ov-main .st-ov-chat { grid-column: 2; }
.st-ov-main.chat-open { grid-template-columns: minmax(0, 1fr) min(440px, 44vw); }
.st-ov-main.chat-open .st-ov-chat { display: flex; min-height: 0; padding: 0; overflow: hidden; }
/* a closed chat must NOT reserve a column (mountInline leaves .chat-window on
   the aside, whose display:grid would otherwise occupy width) */
.st-ov-main:not(.chat-open) .st-ov-chat { display: none !important; }
