:root {
  --chat-menu-bg: #fff; --chat-menu-text: #242428; --chat-menu-muted: #73737c;
  --chat-menu-border: #e5e5e8; --chat-menu-hover: #f2f2f4; --chat-menu-divider: #e9e9ed;
  --chat-menu-danger: #d92d20; --chat-menu-danger-hover: #b42318; --chat-menu-danger-bg: #fff0ef;
}
.side-top .brand { margin-right: auto; }
#searchChats { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 32px; }
#historyMore { width: calc(100% - 24px); margin: 4px 12px; flex-shrink: 0; font-size: 12px; }
.chat-search-dialog { width: min(600px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow: auto; }
.chat-search-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.chat-search-heading h2 { margin: 0; }
.chat-search-dialog .stack { margin-top: 12px; }
.chat-search-dialog input, .chat-search-dialog select { min-width: 0; width: 100%; }
.chat-search-dialog select { padding: 7px 10px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--bg-input); }
.chat-search-results { max-height: 45dvh; overflow-y: auto; overscroll-behavior: contain; }
.chat-search-result { width: 100%; display: flex; flex-direction: column; align-items: stretch; gap: 4px; background: transparent; border: none; text-align: left; padding: 12px; border-radius: 10px; }
.chat-search-result:hover, .chat-search-result:focus-visible { background: var(--hover); }
.chat-search-result strong { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-search-snippet { font-size: 12px; color: var(--muted); white-space: normal; overflow-wrap: anywhere; }
#searchMore { width: 100%; margin-top: 8px; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --chat-menu-bg: #242426; --chat-menu-text: #f4f4f5; --chat-menu-muted: #a1a1aa;
    --chat-menu-border: #3e3e42; --chat-menu-hover: #343438; --chat-menu-divider: #414145;
    --chat-menu-danger: #f87171; --chat-menu-danger-hover: #fca5a5; --chat-menu-danger-bg: rgba(248,113,113,.1);
  }
}
:root[data-theme="dark"] {
  --chat-menu-bg: #242426; --chat-menu-text: #f4f4f5; --chat-menu-muted: #a1a1aa;
  --chat-menu-border: #3e3e42; --chat-menu-hover: #343438; --chat-menu-divider: #414145;
  --chat-menu-danger: #f87171; --chat-menu-danger-hover: #fca5a5; --chat-menu-danger-bg: rgba(248,113,113,.1);
}
.history-heading { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding-right: 12px; }
.history-heading .side-label { margin-right: 0; }
.history-heading .side-label { flex: 1; }
#manageSections { border: none; padding: 4px; color: var(--muted); min-width: 24px; }
.history-section { margin-top: 12px; min-width: 0; }
.history-section > summary { padding: 6px 8px; color: var(--muted); font-size: 12px; cursor: pointer; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.history-section p { padding: 0 8px; }
#sectionDialog { max-height: calc(100dvh - 32px); overflow-y: auto; }
#sectionDialog .stack { margin: 14px 0 8px; }
#sectionDialog input, #sectionDialog select { min-width: 0; width: 100%; }
#sectionDialog input[type="checkbox"] { width: auto; }
#archiveHistory { border: none; padding: 4px; color: var(--muted); font-size: 11px; white-space: nowrap; }
.history .chat-row { display: flex; align-items: center; gap: 2px; border-radius: 8px; min-height: 38px; }
.history .chat-row:hover, .history .chat-row:focus-within { background: var(--hover); }
.history .chat-row.active { background: var(--selected); }
.history .chat-row a { flex: 1; min-width: 0; background: transparent; }
.history .chat-row a[aria-current="page"] { background: transparent; }
.history .chat-row.unread a { font-weight: 700; }
.chat-more { border: none; background: transparent; width: 30px; height: 32px; padding: 7px; flex: 0 0 30px; color: var(--muted); }
.chat-more:hover, .chat-more[aria-expanded="true"] { color: var(--text); background: var(--bg-soft); }
.chat-pin { display: flex; align-items: center; padding-right: 8px; color: var(--muted); }
.luxi-chat-menu {
  position: fixed; z-index: 10000; width: 252px; max-width: calc(100vw - 16px); overflow-y: auto;
  padding: 6px; background: var(--chat-menu-bg); color: var(--chat-menu-text);
  border: 1px solid var(--chat-menu-border); border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,.28), 0 18px 46px rgba(0,0,0,.15);
  font: 13px/1.4 var(--font); user-select: none; transform-origin: top left;
  animation: luxi-menu-in 150ms ease-out;
}
.luxi-chat-menu__item {
  width: 100%; min-height: 38px; display: flex; align-items: center; gap: 12px; padding: 0 11px;
  border: none; border-radius: 7px; background: transparent; color: var(--chat-menu-text);
  font: 400 13px/1.4 var(--font); text-align: left; white-space: nowrap;
  transition: background-color 140ms ease, color 140ms ease;
}
.luxi-chat-menu__item:hover, .luxi-chat-menu__item:focus-visible { background: var(--chat-menu-hover); outline: none; }
.luxi-chat-menu__icon { width: 16px; height: 16px; flex: 0 0 16px; display: block; }
.luxi-chat-menu__label { flex: 1; }
.luxi-chat-menu__divider { height: 1px; margin: 5px 6px; background: var(--chat-menu-divider); }
.luxi-chat-menu__item--danger { color: var(--chat-menu-danger); }
.luxi-chat-menu__item--danger:hover, .luxi-chat-menu__item--danger:focus-visible { color: var(--chat-menu-danger-hover); background: var(--chat-menu-danger-bg); }
@keyframes luxi-menu-in { from { opacity: 0; transform: translateY(-4px) scale(.985); } to { opacity: 1; transform: none; } }
@media (max-width: 640px) { .luxi-chat-menu { width: 240px; } .luxi-chat-menu__item { min-height: 42px; } }
:root[data-motion="off"] .luxi-chat-menu, :root[data-motion="off"] .luxi-chat-menu__item { animation: none !important; transition: none !important; }
@media (prefers-reduced-motion: reduce) { .luxi-chat-menu, .luxi-chat-menu__item { animation: none !important; transition: none !important; } }
