/* Hidden until the English text is in (applyI18n adds .lrm-i18n); shown after 1.5 s regardless. */
html:not(.lrm-i18n) body { visibility: hidden; animation: lrm-reveal 0s linear 1.5s forwards; }
@keyframes lrm-reveal { to { visibility: visible; } }

/* LRMagent console in the OpenBot layout: a quiet sidebar holding the brand,
   search, conversations and the menu, and the page as one rounded card beside it.
   Only the logo is LRM's; colours and type follow OpenBot (Inter, neutral greys).
   Loaded last so it wins over the stock sheets. shell.js moves the pieces. */

:root {
    --lrm-sidebar: #ededf5;
    --lrm-sidebar-hover: rgba(24, 24, 27, 0.05);
    --lrm-sidebar-active: #dfdfe8;
    --lrm-card: #f9f9fb;
    --lrm-surface: #ffffff;
    --lrm-line: #dbdbe5;
    --lrm-text: #0a0a0f;
    --lrm-text-2: #3f3f46;
    --lrm-muted: #64646c;
    --lrm-ring: #7480f1;
}
.dark {
    --lrm-sidebar: #0d0b13;
    --lrm-sidebar-hover: rgba(255, 255, 255, 0.05);
    --lrm-sidebar-active: rgba(190, 194, 255, 0.12);
    --lrm-card: #13101b;
    --lrm-surface: #1a1624;
    --lrm-line: #2b2538;
    --lrm-text: #f0f0f4;
    --lrm-text-2: #c9c9d2;
    --lrm-muted: #9a9aa6;
    --lrm-ring: #8d97ff;
}

body { font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif; letter-spacing: -0.005em; }
[hidden] { display: none !important; }

/* ---- Frame: sidebar on the canvas, the page as a card ---- */
#app { background: var(--lrm-sidebar); }
@media (min-width: 1024px) {
    #main-content {
        height: calc(100vh - 16px) !important;
        margin: 8px 8px 8px 0;
        border: 1px solid var(--lrm-line);
        border-radius: 14px;
        overflow: hidden;
        background: var(--lrm-card);
    }
}
#main-content > header {
    background: transparent !important;
    border-bottom-color: transparent !important;
    height: 48px;
}
#session-toggle-btn, #theme-toggle, #logout-btn-header { display: none !important; }

/* ---- Sidebar ---- */
#sidebar {
    width: 288px !important;
    background: var(--lrm-sidebar) !important;
    backdrop-filter: none !important;
    color: var(--lrm-text-2);
    border-right: 0 !important;
}
#sidebar .border-white\/10 { border-color: transparent !important; }
#sidebar .sidebar-brand { height: 56px; padding: 0 12px 0 16px; gap: 10px; border-bottom: 0 !important; }
#sidebar-home { width: 30px !important; height: 30px !important; border-radius: 8px; border: 1px solid var(--lrm-line); }
.lrm-wordtext { height: 26px; width: auto; max-width: 100%; }
.lrm-wordmark { height: 56px; width: auto; max-width: 80vw; }
.lrm-on-dark { display: none; }
.dark .lrm-on-light { display: none; }
.dark .lrm-on-dark { display: block; }
.lrm-icon-btn {
    width: 30px; height: 30px; border-radius: 8px; border: 0; background: none; cursor: pointer;
    color: var(--lrm-text); display: inline-grid; place-items: center; flex: none;
}
.lrm-icon-btn:hover { background: var(--lrm-sidebar-hover); }
.lrm-new-chat { margin-left: auto; }

.lrm-search { position: relative; margin: 2px 12px 10px; }
.lrm-search i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); font-size: 12px; color: var(--lrm-muted); }
.lrm-search input {
    width: 100%; height: 36px; border-radius: 10px; border: 1px solid var(--lrm-line);
    background: var(--lrm-surface); padding: 0 10px 0 32px; font-size: 14px; color: var(--lrm-text); outline: none;
}
.lrm-search input:focus { border-color: var(--lrm-ring); box-shadow: 0 0 0 3px rgba(116, 128, 241, 0.18); }

/* Chats: the conversation list is a page over the main area (sidebar → Chats). */
#content-area { position: relative; }
.lrm-chats { position: absolute; inset: 0; z-index: 30; background: var(--lrm-card); overflow-y: auto; padding: 36px 24px 48px; }
.lrm-chats[hidden] { display: none !important; }
.lrm-chats > * { max-width: 820px; margin-left: auto !important; margin-right: auto !important; }
.lrm-chats-head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.lrm-chats-head h1 { font-size: 24px; font-weight: 650; margin: 0; flex: 1; color: var(--lrm-text); }
.lrm-chats-new { display: inline-flex; align-items: center; gap: 8px; border: 0; border-radius: 10px; padding: 8px 14px; cursor: pointer;
    font: inherit; font-size: 14px; font-weight: 550; background: var(--lrm-text); color: var(--lrm-card); }
.lrm-chats .lrm-search { display: block; box-sizing: border-box; width: 100%; max-width: 820px; margin: 0 auto 18px !important; }
.lrm-chats .lrm-search input { width: 100%; box-sizing: border-box; }
.lrm-chats .lrm-search input { height: 42px; font-size: 15px; }
.lrm-chats #session-panel {
    display: flex !important; position: static !important; inset: auto !important; transform: none !important; z-index: auto !important;
    width: auto !important; height: auto !important; box-shadow: none !important; animation: none !important;
    background: transparent; border: 0; overflow: visible; flex-direction: column;
}
.lrm-chats #session-panel .session-panel-header { display: none; }
.lrm-chats #session-panel .session-panel-new-wrap { height: 0; padding: 0; margin: 0; overflow: visible; }
.lrm-chats #session-panel .session-panel-new { display: none; }
.lrm-chats #session-list { padding: 0; overflow: visible; max-height: none; }
.lrm-chats .session-item { border-radius: 10px; color: var(--lrm-text); padding: 11px 12px !important; font-size: 14.5px; }
.lrm-chats .session-item:hover { background: var(--lrm-sidebar-hover); }
.lrm-chats .session-item.active { background: var(--lrm-sidebar-active); }
#sidebar .lrm-chats-item { display: flex; align-items: center; gap: 11px; margin: 4px 12px 6px; cursor: pointer; text-decoration: none; }
.lrm-empty-list {
    flex: 1 1 auto; display: flex; flex-direction: column; justify-content: center; max-height: 360px;
    margin: 4px 0; padding: 36px 18px; border: 1px dashed var(--lrm-line); border-radius: 12px;
    text-align: center; font-size: 14px; color: var(--lrm-muted); line-height: 1.5;
}
.lrm-empty-list b { display: block; color: var(--lrm-text); font-weight: 600; margin-bottom: 6px; }

/* Menu: short labelled sections (Assistants, Knowledge, Connect, Work, Settings). */
#sidebar #sidebar-nav { flex: 0 1 auto !important; max-height: 68vh; padding: 6px 12px 4px !important; overflow-y: auto; }
#sidebar .menu-group { margin: 0 0 8px !important; }
#sidebar .menu-group-head {
    display: flex !important; pointer-events: none; padding: 6px 10px 3px !important; text-transform: none !important;
    letter-spacing: 0.01em !important; font-size: 11.5px !important; font-weight: 600 !important; color: var(--lrm-muted) !important;
}
#sidebar .menu-group-head .chevron, #sidebar .menu-group-edit { display: none !important; }
#sidebar .menu-group[data-group="chat"] { display: none !important; }
#sidebar .menu-group-items { padding-left: 0 !important; display: block !important; }
#sidebar .sidebar-item {
    color: var(--lrm-text) !important; font-weight: 450; font-size: 13.5px !important; line-height: 1.35;
    padding: 7px 10px !important; border-radius: 9px !important; gap: 11px !important;
}
#sidebar .sidebar-item .item-icon { color: var(--lrm-text) !important; opacity: 0.55; font-size: 12.5px !important; }
#sidebar .sidebar-item:hover { background: var(--lrm-sidebar-hover) !important; }
#sidebar .sidebar-item:hover .item-icon, #sidebar .sidebar-item.active .item-icon { opacity: 0.9; }
#sidebar .sidebar-item.active { background: var(--lrm-sidebar-active) !important; color: var(--lrm-text) !important; font-weight: 550; }
#sidebar-nav:hover::-webkit-scrollbar-thumb { background: rgba(15, 23, 42, 0.18); }
#sidebar .sidebar-item[data-view="chat"] { display: none !important; }
#sidebar #sidebar-nav { flex: 1 1 auto !important; max-height: none; }
#session-list .session-empty { display: none; }

.lrm-account { display: flex; align-items: center; gap: 8px; padding: 6px 12px 10px 22px; }
.lrm-avatar {
    width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; flex: none;
    background: var(--lrm-sidebar-active); color: var(--lrm-text-2); font-size: 12px; font-weight: 600;
}
.lrm-account .lrm-name { font-size: 14px; color: var(--lrm-text); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#sidebar .sidebar-footer { background: transparent !important; border-top: 0 !important; }

/* ---- New chat: greeting, the composer in the middle, agents to start with ---- */
#chat-main { display: flex; flex-direction: column; }
#chat-main.lrm-empty { justify-content: center; }
#chat-main.lrm-empty #chat-messages { flex: 0 0 auto; overflow: visible; }
#chat-main.lrm-empty #welcome-screen { height: auto !important; padding: 0 24px 22px !important; }
#chat-main.lrm-empty #chat-composer { border-top: 0 !important; background: transparent !important; }
#chat-composer { background: transparent !important; border-top-color: transparent !important; }
.lrm-greeting { font-size: 24px; font-weight: 650; letter-spacing: -0.02em; color: var(--lrm-text); text-align: center; margin: 0; }
.lrm-hint { text-align: center; font-size: 12px; color: var(--lrm-muted); margin: 8px 0 0; }
#lrm-explore { display: none; width: 100%; max-width: 48rem; margin: 26px auto 0; padding: 0 16px 24px; }
#chat-main.lrm-empty #lrm-explore { display: block; }
#lrm-explore h2 { font-size: 15px; font-weight: 600; color: var(--lrm-text); margin: 0 0 14px; }
.lrm-bot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.lrm-bot {
    display: flex; align-items: center; gap: 12px; text-align: left; width: 100%;
    padding: 14px 14px; border-radius: 12px; border: 1px solid var(--lrm-line);
    background: var(--lrm-surface); cursor: pointer; color: inherit; font: inherit;
    transition: border-color .15s, box-shadow .15s;
}
.lrm-bot:hover { border-color: #c8c8d4; box-shadow: 0 2px 10px rgba(16, 16, 32, 0.06); }
.dark .lrm-bot:hover { border-color: #3a334a; }
.lrm-bot .lrm-orb { width: 32px; height: 32px; border-radius: 50%; flex: none; overflow: hidden; display: grid; place-items: center; }
.lrm-bot .lrm-orb img { width: 100%; height: 100%; object-fit: cover; }
.lrm-bot b { display: block; font-size: 14px; font-weight: 550; color: var(--lrm-text); }
.lrm-bot small { display: block; font-size: 12px; color: var(--lrm-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 210px; }
.lrm-bot.lrm-bot-new .lrm-orb { background: var(--lrm-sidebar); color: var(--lrm-text-2); }

/* Composer: OpenBot's rounded white box. */
#composer-card { border-radius: 16px !important; border: 1px solid var(--lrm-line) !important; background: var(--lrm-surface) !important; box-shadow: none !important; }
#composer-card:focus-within { border-color: #c8c8d4 !important; box-shadow: 0 0 0 3px rgba(116, 128, 241, 0.12) !important; }

/* ---- Small screens: the stock off-canvas sidebar, full-width page ---- */
@media (max-width: 1023px) {
    #sidebar { width: min(300px, 86vw) !important; }
    .lrm-chats { padding: 20px 14px 40px; }
    .lrm-greeting { font-size: 21px; }
}

/* One language only, so no switcher in the header or in Settings → System. */
#lang-selector,
div:has(> #cfg-lang-select) { display: none !important; }

/* Upstream project links (docs, website, GitHub) are not part of this deployment. */
#docs-link,
a[href="https://cowagent.ai"],
a[href^="https://github.com/zhayujie/"] { display: none !important; }

/* ---- Shape and focus ---- */
.rounded-lg { border-radius: 10px; }
.rounded-xl { border-radius: 12px; }
.rounded-2xl { border-radius: 16px; }
:where(a, button, [role="button"]):focus-visible { outline: 2px solid var(--lrm-ring); outline-offset: 2px; }

/* Settings the deployment owns (the server refuses them too): the console
   password, the listen address and the in-place updater. */
div:has(> #cfg-password),
div:has(> #cfg-password-save),
#cfg-listen-row,
#update-action-item { display: none !important; }

/* Approve / Deny on a tool call that waits for the owner (shell.js). */
.lrm-approve { display: flex; gap: 8px; align-items: center; margin: 8px 0 4px; font-size: 13px; font-weight: 600; }
.lrm-approve button { font: 600 13px Inter, system-ui, sans-serif; border-radius: 9px; padding: 6px 12px; cursor: pointer;
    border: 1px solid var(--lrm-line); background: var(--lrm-surface); color: var(--lrm-text); }
.lrm-approve button[data-d="approve"] { background: #18181b; border-color: #18181b; color: #fff; }
.dark .lrm-approve button[data-d="approve"] { background: #f0f0f4; border-color: #f0f0f4; color: #13101b; }
.lrm-approve button:disabled { opacity: .5; }

/* Tool steps fold into one line per answer (shell.js adds the toggle). */
.agent-steps:not(.lrm-steps-open) > .agent-tool-step:not(.tool-streaming) { display: none !important; }
.lrm-steps-toggle { display: inline-flex; align-items: center; gap: 7px; border: 0; background: none; padding: 4px 8px; margin: 0 0 4px -8px;
    border-radius: 8px; cursor: pointer; font: inherit; font-size: 13px; color: var(--lrm-muted); }
.lrm-steps-toggle:hover { background: var(--lrm-sidebar-hover); color: var(--lrm-text); }
.lrm-steps-toggle .fa-check { color: #16a34a; }
.lrm-steps-failed { color: #dc2626; }
.lrm-steps-chev { font-size: 10px; opacity: .7; }

/* Chats page: agent chips, who/where/when under each title, WhatsApp section, transcript. */
.lrm-chat-chips { display: flex; gap: 6px; flex-wrap: wrap; margin: -6px auto 16px !important; }
.lrm-chip { border: 1px solid var(--lrm-line); background: var(--lrm-surface); color: var(--lrm-text-2); border-radius: 999px; padding: 5px 12px;
    font: inherit; font-size: 13px; cursor: pointer; }
.lrm-chip[aria-pressed="true"] { background: var(--lrm-text); color: var(--lrm-card); border-color: var(--lrm-text); }
.lrm-chats .session-item { display: grid !important; grid-template-columns: 22px 1fr auto; grid-template-rows: auto auto; column-gap: 8px; align-items: center; }
.lrm-chats .session-item > .session-icon, .lrm-chats .session-item > .session-faces { grid-row: 1 / span 2; }
.lrm-chats .session-item .session-title { grid-column: 2; font-weight: 550; }
.lrm-chats .session-item .lrm-chat-meta { grid-column: 2; font-size: 12.5px; color: var(--lrm-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lrm-chats .session-item .lrm-chat-meta b { color: var(--lrm-text-2); font-weight: 600; }
.lrm-chats .session-item > button:not(.lrm-wa-item) { grid-row: 1 / span 2; }
.lrm-console-head, .lrm-wa-head { font-size: 11.5px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--lrm-muted); margin: 6px 12px 2px; }
.lrm-wa { margin-top: 20px; }
.lrm-wa[hidden] { display: none; }
.lrm-wa-item { width: 100%; text-align: left; border: 0; background: none; font: inherit; cursor: pointer; }
.lrm-wa-item .fa-whatsapp { color: #25d366; }
.lrm-back { border: 0; background: none; font: inherit; font-size: 14px; color: var(--lrm-muted); cursor: pointer; padding: 4px 0; margin-bottom: 8px; }
.lrm-transcript h2 { font-size: 19px; margin: 0 0 16px; color: var(--lrm-text); }
.lrm-t { display: flex; flex-direction: column; margin: 0 0 12px; max-width: 78%; }
.lrm-t.assistant { margin-left: auto; align-items: flex-end; }
.lrm-t-bubble { background: var(--lrm-surface); border: 1px solid var(--lrm-line); border-radius: 14px; padding: 9px 13px; white-space: pre-wrap; font-size: 14.5px; color: var(--lrm-text); }
.lrm-t.assistant .lrm-t-bubble { background: var(--lrm-sidebar-active); }
.lrm-t small { font-size: 11.5px; color: var(--lrm-muted); margin-top: 3px; }
.lrm-chats .lrm-hide { display: none !important; }

/* New chat: pick the agent. */
.lrm-picker { position: fixed; z-index: 2000; width: 300px; max-height: 70vh; overflow: auto; background: var(--lrm-surface); border: 1px solid var(--lrm-line);
    border-radius: 14px; box-shadow: 0 18px 50px rgba(0,0,0,.18); padding: 6px; }
.lrm-picker-head { font-size: 11.5px; font-weight: 650; letter-spacing: .05em; text-transform: uppercase; color: var(--lrm-muted); padding: 8px 10px 4px; }
.lrm-picker button { display: flex; gap: 10px; align-items: center; width: 100%; border: 0; background: none; text-align: left; padding: 8px 10px; border-radius: 10px; cursor: pointer; font: inherit; color: var(--lrm-text); }
.lrm-picker button:hover { background: var(--lrm-sidebar-hover); }
.lrm-picker b { display: block; font-size: 14px; font-weight: 600; }
.lrm-picker small { display: block; font-size: 12px; color: var(--lrm-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.lrm-picker-orb { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--lrm-sidebar-active); flex: none; overflow: hidden; }

/* Tasks form: "Also send to" (several WhatsApp recipients) */
#lrm-receivers { margin-top: 10px; display: grid; gap: 4px; }
#lrm-receivers .lrm-recv-title { font-size: 12px; font-weight: 600; color: var(--lrm-muted); }
#lrm-receivers .lrm-recv { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 3px 0; min-height: 36px; cursor: pointer; }
@media (pointer: coarse) { #lrm-receivers .lrm-recv { min-height: 44px; } }
#lrm-receivers .lrm-recv input { width: auto; margin: 0; }
#lrm-receivers .lrm-recv small, #lrm-receivers .lrm-recv-none { color: var(--lrm-muted); font-size: 12px; }

/* Agents page grouped by the Team page: a heading per group, Level 2 under its Level 1. */
.lrm-agent-section { display: flex; align-items: baseline; gap: 8px; margin: 14px 4px 4px; font-size: 12.5px; font-weight: 650; color: rgb(var(--cw-slate-700)); }
.lrm-agent-section.first { margin-top: 2px; }
.lrm-agent-section small { font-weight: 500; color: rgb(var(--cw-slate-500)); }
.lrm-agent-place { font-size: 11.5px; font-weight: 600; color: rgb(var(--cw-slate-600)); margin: 1px 0; }
.agent-card.lrm-l2 { margin-left: 18px; position: relative; }
.agent-card.lrm-l2::before { content: ''; position: absolute; left: -10px; top: 6px; bottom: 6px; width: 2px; border-radius: 2px; background: rgb(var(--cw-slate-200)); }
.lrm-agent-arrange { margin: 14px 4px 4px; padding: 8px 10px; border: 1px dashed rgb(var(--cw-slate-300)); border-radius: 10px; background: none; color: rgb(var(--cw-slate-600)); font-size: 12.5px; font-weight: 600; cursor: pointer; text-align: center; }
.lrm-agent-arrange:hover { background: rgb(var(--cw-slate-50)); color: rgb(var(--cw-slate-800)); }
