:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #d8dee9;
  background: #0b0f14;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body, #app { margin: 0; width: 100%; height: 100%; overflow: hidden; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.app-shell { display: grid; grid-template-rows: 48px 1fr; background: #0b0f14; }
.topbar { display: grid; grid-template-columns: 170px minmax(320px, 1fr) auto; align-items: center; gap: 12px; padding: 0 10px; border-bottom: 1px solid #242b35; background: #11161d; }
.brand { font-weight: 800; letter-spacing: .2px; }
.address-wrap { display: grid; grid-template-columns: 34px 34px 1fr 44px 34px; gap: 5px; }
.address-wrap input, .composer textarea { background: #0b1016; color: #e8edf3; border: 1px solid #303946; border-radius: 7px; outline: none; }
.address-wrap input { height: 32px; padding: 0 10px; }
.address-wrap button, .account-area button, .chat-panel button { background: #1a222c; color: #e7edf3; border: 1px solid #303946; border-radius: 6px; }
.address-wrap button:hover, .account-area button:hover, .chat-panel button:hover { background: #26303c; }
.account-area { display: flex; align-items: center; gap: 8px; font-size: 12px; white-space: nowrap; }
.connection-dot { width: 8px; height: 8px; border-radius: 50%; background: #6f7782; }
.connection-dot.online { background: #32d583; box-shadow: 0 0 8px rgba(50,213,131,.6); }
#login-btn { padding: 7px 10px; }
.profile-btn { width: 32px; height: 32px; border-radius: 50% !important; background-size: cover !important; background-position: center !important; }

.workspace { min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 400px; }
.workspace.chat-collapsed { grid-template-columns: minmax(0, 1fr) 42px; }
.browser-pane { position: relative; min-width: 0; background: #080b10; overflow: hidden; }
.browser-hint { position: absolute; left: 12px; top: 12px; z-index: 2; max-width: 640px; padding: 7px 10px; border-radius: 6px; background: rgba(12,17,24,.88); color: #9da9b7; font-size: 11px; pointer-events: none; }
#browser-frame { width: 100%; height: 100%; border: 0; background: #e8e8e8; }
.research-workspace { position: absolute; inset: 0; z-index: 1; display: grid; grid-template-rows: 38px minmax(0, 1fr); background: #0b0f14; }
.research-toolbar { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 0 9px; border-bottom: 1px solid #242b35; background: #10161e; }
.research-mode { display: flex; align-items: center; gap: 7px; white-space: nowrap; font-size: 11px; }
.research-live-dot { width: 7px; height: 7px; border-radius: 50%; background: #32d583; box-shadow: 0 0 7px rgba(50,213,131,.45); }
.research-mode-note { color: #748293; font-size: 9px; }
.research-markets { min-width: 0; display: flex; justify-content: center; gap: 5px; overflow: hidden; }
.market-chip, #research-open-external { height: 26px; padding: 0 8px; border: 1px solid #303946; border-radius: 6px; background: #171f29; color: #dce5ef; font-size: 10px; }
.market-chip:hover, #research-open-external:hover { background: #243140; }
#research-open-external { white-space: nowrap; }
#tradingview-widget { position: relative; min-width: 0; min-height: 0; width: 100%; height: 100%; background: #0b0f14; }
#tradingview-widget > iframe, #tradingview-widget .tradingview-widget-container__widget { width: 100% !important; height: 100% !important; }
.research-loading { position: absolute; inset: 0; display: grid; place-items: center; color: #758394; font-size: 12px; background: linear-gradient(180deg, #0c1118, #090d12); }

.chat-panel { min-width: 0; border-left: 1px solid #242b35; background: #10151c; display: grid; grid-template-rows: 36px 52px auto 1fr auto auto; overflow: hidden; }
.workspace.chat-collapsed .chat-panel > *:not(.room-header) { display: none; }
.workspace.chat-collapsed .room-header { height: 100%; writing-mode: vertical-rl; padding: 8px 3px; justify-content: flex-start; }
.workspace.chat-collapsed .room-header > div { display: none; }
.workspace.chat-collapsed #collapse-chat { transform: rotate(180deg); }
.chat-tabs { display: grid; grid-template-columns: 1fr 1fr 1fr; border-bottom: 1px solid #242b35; }
.chat-tabs .tab { border: 0; border-radius: 0; background: transparent; color: #8f9baa; }
.chat-tabs .tab.active { color: #fff; border-bottom: 2px solid #4d8dff; }
.room-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 9px; border-bottom: 1px solid #242b35; }
.room-name { font-weight: 800; font-size: 14px; }
.room-subtitle { font-size: 10px; color: #8895a5; margin-top: 2px; }
#collapse-chat { width: 28px; height: 28px; }
.room-list { max-height: 100px; overflow-y: auto; border-bottom: 1px solid #242b35; padding: 5px; }
.room-chip { width: 100%; text-align: left; padding: 6px 8px; border: 0 !important; background: transparent !important; color: #aab6c5 !important; }
.room-chip.active { background: #192330 !important; color: #fff !important; }
.message-list { min-height: 0; overflow-y: auto; padding: 8px 9px 18px; scroll-behavior: smooth; }
.empty-state { color: #768393; font-size: 12px; text-align: center; padding: 30px 12px; }
.message { position: relative; padding: 8px 7px; border-radius: 7px; }
.message:hover { background: #151c25; }
.message-head { display: flex; align-items: center; gap: 7px; min-height: 22px; }
.message-author { font-weight: 700; font-size: 12px; color: #eef3f8; }
.message-time, .message-edited { font-size: 9px; color: #6e7a89; }
.message-tools { margin-left: auto; display: flex; gap: 3px; opacity: 0; transition: opacity .12s ease; }
.message:hover .message-tools, .message:focus-within .message-tools { opacity: 1; }
.message-tools button { min-width: 25px; height: 24px; padding: 0 5px; border-color: #28323f; background: #111821; font-size: 11px; }
.message-body { margin-top: 3px; font-size: 13px; line-height: 1.38; white-space: pre-wrap; overflow-wrap: anywhere; }
.cashtag { color: #61a6ff; font-weight: 700; }
.reply-preview { width: 100%; display: flex; align-items: stretch; gap: 7px; margin: 4px 0 3px; padding: 4px 6px !important; border: 0 !important; background: transparent !important; color: #92a0b0 !important; text-align: left; font-size: 10px; }
.reply-preview strong { display: block; color: #b8c5d4; font-size: 10px; }
.reply-preview span span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 300px; }
.reply-rule { width: 3px; min-width: 3px; border-radius: 3px; background: #486fa8; }
.reply-jump:hover { background: #131b24 !important; }
.reaction-row { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.reaction-pill { display: inline-flex; align-items: center; gap: 4px; height: 25px; padding: 0 7px !important; border-radius: 12px !important; font-size: 11px; background: #151e29 !important; border-color: #2a3542 !important; }
.reaction-pill.reacted { background: #17365f !important; border-color: #3b75ba !important; color: #dcecff !important; }
.message-media-link { display: block; margin-top: 7px; }
.message-media { display: block; width: 100%; max-height: 260px; object-fit: contain; border: 1px solid #283441; border-radius: 7px; background: #090d12; }
.symbol-strip { padding: 6px 9px; border-top: 1px solid #242b35; font-size: 11px; color: #97a7ba; }
.symbol-pill { display: inline-block; margin-right: 5px; padding: 3px 6px; border-radius: 12px; background: #182331; color: #69aaff; }
.composer { border-top: 1px solid #242b35; padding: 8px; background: #0f141b; }
.composer textarea { width: 100%; height: 62px; resize: none; padding: 8px; }
.composer-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; }
.composer-left { min-width: 0; display: flex; align-items: center; gap: 7px; }
.composer-help { font-size: 10px; color: #6f7c8d; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#attach-btn { padding: 5px 8px; font-size: 10px; white-space: nowrap; }
#attach-btn:disabled, #send-btn:disabled { opacity: .45; cursor: default; }
#send-btn { padding: 6px 12px; background: #2764d8; border-color: #2764d8; }
.reply-bar, .media-preview { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; padding: 6px 7px; border: 1px solid #283442; border-radius: 7px; background: #131a23; font-size: 10px; color: #aebac8; }
.reply-bar span, .media-preview span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reply-bar button, .media-preview button { width: 24px; height: 24px; padding: 0; }
.media-preview img { width: 40px; height: 40px; object-fit: cover; border-radius: 5px; border: 1px solid #303b49; }

@media (max-width: 850px) {
  .topbar { grid-template-columns: 1fr auto; }
  .brand { display: none; }
  .workspace { grid-template-columns: 1fr; }
  .browser-pane { display: none; }
  .chat-panel { border-left: 0; }
  .account-area #connection-label { display: none; }
  .message-tools { opacity: 1; }
}
