:root {
  --bg: #0e0e11;
  --panel: #131316;
  --panel2: #101013;
  --text: #dcdce0;
  --muted: #6b6b75;
  --line: rgba(255, 255, 255, 0.06);
  --primary: #dcdce0;
  --primary-accent: #a78bfa;
  --danger: #ef4444;
  --success: #34d399;
  --warning: #fbbf24;
  --radius: 8px;
  --radius-sm: 6px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.15);
  --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.35);
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei UI", sans-serif;
}

:root[data-theme="light"] {
  --bg: #ededed;
  --panel: #f4f4f4;
  --panel2: #f0f0f0;
  --text: #1a1a1a;
  --muted: #888;
  --line: rgba(0, 0, 0, 0.08);
  --primary: #1a1a1a;
  --primary-accent: #6b6bf0;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #d97706;
  --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.07);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.10);
}

:root[data-theme="light"] .left-list,
:root[data-theme="light"] .pdf-view,
:root[data-theme="light"] .chat-log,
:root[data-theme="light"] .sessions-list,
:root[data-theme="light"] .schema-view,
:root[data-theme="light"] .settings-docs {
  scrollbar-color: rgba(15, 23, 42, 0.22) transparent;
}

:root[data-theme="light"] .left-list::-webkit-scrollbar-thumb,
:root[data-theme="light"] .pdf-view::-webkit-scrollbar-thumb,
:root[data-theme="light"] .chat-log::-webkit-scrollbar-thumb,
:root[data-theme="light"] .sessions-list::-webkit-scrollbar-thumb,
:root[data-theme="light"] .schema-view::-webkit-scrollbar-thumb,
:root[data-theme="light"] .settings-docs::-webkit-scrollbar-thumb {
  background: rgba(15, 23, 42, 0.18);
}

:root[data-theme="light"] .btn,
:root[data-theme="light"] .tab-btn {
  background: transparent;
  border-color: rgba(0, 0, 0, 0.12);
}

:root[data-theme="light"] .btn:hover,
:root[data-theme="light"] .tab-btn:hover {
  border-color: rgba(0, 0, 0, 0.22);
  background: rgba(0, 0, 0, 0.03);
}

:root[data-theme="light"] .btn-primary,
:root[data-theme="light"] .tab-btn.active {
  background: var(--text);
  border-color: var(--text);
  color: #fff;
}

:root[data-theme="light"] .btn-primary:hover {
  opacity: 0.85;
}

:root[data-theme="light"] .btn-danger {
  border-color: rgba(220, 38, 38, 0.30);
  color: var(--danger);
  background: transparent;
}

:root[data-theme="light"] .btn-danger:hover {
  background: rgba(220, 38, 38, 0.06);
  border-color: rgba(220, 38, 38, 0.45);
}

:root[data-theme="light"] .input:focus,
:root[data-theme="light"] .textarea:focus {
  border-color: rgba(37, 99, 235, 0.40);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
  background: rgba(255, 255, 255, 0.85);
}

:root[data-theme="light"] .msg {
  box-shadow: 0 10px 24px rgba(2, 6, 23, 0.10);
}

:root[data-theme="light"] .msg.assistant,
:root[data-theme="light"] .insp-card,
:root[data-theme="light"] .cat-item {
  background: rgba(15, 23, 42, 0.03);
}

:root[data-theme="light"] .insp-quote {
  border-color: rgba(15, 23, 42, 0.10);
  background: rgba(15, 23, 42, 0.04);
}

:root[data-theme="light"] .insp-note {
  background: rgba(255, 255, 255, 0.78);
}

:root[data-theme="light"] .dropzone {
  border-color: rgba(15, 23, 42, 0.20);
  background: rgba(15, 23, 42, 0.02);
}

:root[data-theme="light"] .dropzone.dragover {
  border-color: rgba(37, 99, 235, 0.45);
  background: rgba(37, 99, 235, 0.06);
}

:root[data-theme="light"] .upload-status {
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(6px);
}

:root[data-theme="light"] .upload-spinner {
  border-color: rgba(15, 23, 42, 0.35);
  border-right-color: transparent;
}

:root[data-theme="light"] .tooltip,
:root[data-theme="light"] .translation-popup {
  background: rgba(255, 255, 255, 0.96);
  color: var(--text);
  border-color: rgba(15, 23, 42, 0.12);
  box-shadow: 0 12px 34px rgba(2, 6, 23, 0.14);
}

:root[data-theme="light"] .context-dropdown-button {
  background: rgba(15, 23, 42, 0.04);
  color: var(--muted);
}

:root[data-theme="light"] .context-dropdown-button:hover {
  background: rgba(15, 23, 42, 0.06);
  border-color: rgba(15, 23, 42, 0.16);
}

:root[data-theme="light"] .context-dropdown-menu {
  box-shadow: 0 10px 30px rgba(2, 6, 23, 0.10);
}

:root[data-theme="light"] .context-dropdown-item:hover {
  background: rgba(15, 23, 42, 0.05);
}

:root[data-theme="light"] .session-menu {
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 12px 34px rgba(2, 6, 23, 0.14);
}

:root[data-theme="light"] .session-menu-item:hover {
  border-color: rgba(15, 23, 42, 0.10);
  background: rgba(15, 23, 42, 0.04);
}

:root[data-theme="light"] .modal {
  background: rgba(15, 23, 42, 0.55);
}

:root[data-theme="light"] .login-box {
  background: rgba(255, 255, 255, 0.92);
  border-color: rgba(15, 23, 42, 0.10);
  box-shadow: 0 22px 70px rgba(2, 6, 23, 0.18);
}

:root[data-theme="light"] .close-modal {
  color: rgba(15, 23, 42, 0.55);
}

:root[data-theme="light"] .close-modal:hover {
  color: rgba(15, 23, 42, 0.92);
}

:root[data-theme="light"] .login-box h2 {
  color: var(--text);
}

:root[data-theme="light"] .login-box p {
  color: var(--muted);
}

:root[data-theme="light"] .input-group input {
  border-color: rgba(15, 23, 42, 0.12);
  background: rgba(255, 255, 255, 0.80);
  color: var(--text);
}

:root[data-theme="light"] .input-group button {
  border-color: rgba(15, 23, 42, 0.12);
  background: rgba(15, 23, 42, 0.04);
  color: var(--text);
}

:root[data-theme="light"] .input-group button:hover {
  background: rgba(15, 23, 42, 0.06);
}

select.input {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 34px;
  background-image:
    linear-gradient(45deg, transparent 50%, rgba(255, 255, 255, 0.55) 50%),
    linear-gradient(135deg, rgba(255, 255, 255, 0.55) 50%, transparent 50%);
  background-position:
    calc(100% - 16px) calc(50% - 2px),
    calc(100% - 11px) calc(50% - 2px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

:root[data-theme="light"] select.input {
  background-image:
    linear-gradient(45deg, transparent 50%, rgba(15, 23, 42, 0.60) 50%),
    linear-gradient(135deg, rgba(15, 23, 42, 0.60) 50%, transparent 50%);
}

select.input option {
  background: var(--panel);
  color: var(--text);
}

:root[data-theme="light"] .settings-page select.doc-move-select {
  background: rgba(15, 23, 42, 0.04);
}

:root[data-theme="light"] .dropzone {
  border-color: rgba(15, 23, 42, 0.20);
  background: rgba(15, 23, 42, 0.02);
}

:root[data-theme="light"] .dropzone.dragover {
  border-color: rgba(37, 99, 235, 0.45);
  background: rgba(37, 99, 235, 0.06);
}

:root[data-theme="light"] .upload-status {
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(6px);
}

:root[data-theme="light"] .upload-spinner {
  border-color: rgba(15, 23, 42, 0.35);
  border-right-color: transparent;
}

:root[data-theme="light"] .context-dropdown-button {
  background: rgba(15, 23, 42, 0.04);
  color: var(--muted);
}

:root[data-theme="light"] .context-dropdown-button:hover {
  background: rgba(15, 23, 42, 0.06);
  border-color: rgba(15, 23, 42, 0.16);
}

:root[data-theme="light"] .context-dropdown-menu {
  box-shadow: 0 10px 30px rgba(2, 6, 23, 0.10);
}

:root[data-theme="light"] .context-dropdown-item:hover {
  background: rgba(15, 23, 42, 0.05);
}

:root[data-theme="light"] .session-menu {
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 12px 34px rgba(2, 6, 23, 0.14);
}

:root[data-theme="light"] .session-menu-item:hover {
  border-color: rgba(15, 23, 42, 0.10);
  background: rgba(15, 23, 42, 0.04);
}

:root[data-theme="light"] .modal {
  background: rgba(15, 23, 42, 0.55);
  color: var(--text);
}

:root[data-theme="light"] .login-box {
  background: rgba(255, 255, 255, 0.92);
  border-color: rgba(15, 23, 42, 0.10);
  box-shadow: 0 22px 70px rgba(2, 6, 23, 0.18);
}

:root[data-theme="light"] .close-modal {
  color: rgba(15, 23, 42, 0.55);
}

:root[data-theme="light"] .close-modal:hover {
  color: rgba(15, 23, 42, 0.92);
}

:root[data-theme="light"] .login-box h2 {
  color: var(--text);
}

:root[data-theme="light"] .login-box p {
  color: var(--muted);
}

:root[data-theme="light"] .input-group input {
  border-color: rgba(15, 23, 42, 0.12);
  background: rgba(255, 255, 255, 0.80);
  color: var(--text);
}

:root[data-theme="light"] .input-group button {
  border-color: rgba(15, 23, 42, 0.12);
  background: rgba(15, 23, 42, 0.04);
  color: var(--text);
}

:root[data-theme="light"] .input-group button:hover {
  background: rgba(15, 23, 42, 0.06);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
}

.left-list,
.pdf-view,
.chat-log,
.sessions-list,
.schema-view,
.settings-docs {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.20) transparent;
}

.left-list::-webkit-scrollbar,
.pdf-view::-webkit-scrollbar,
.chat-log::-webkit-scrollbar,
.sessions-list::-webkit-scrollbar,
.schema-view::-webkit-scrollbar,
.settings-docs::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.left-list::-webkit-scrollbar-track,
.pdf-view::-webkit-scrollbar-track,
.chat-log::-webkit-scrollbar-track,
.sessions-list::-webkit-scrollbar-track,
.schema-view::-webkit-scrollbar-track,
.settings-docs::-webkit-scrollbar-track {
  background: transparent;
}

.left-list::-webkit-scrollbar-thumb,
.pdf-view::-webkit-scrollbar-thumb,
.chat-log::-webkit-scrollbar-thumb,
.sessions-list::-webkit-scrollbar-thumb,
.schema-view::-webkit-scrollbar-thumb,
.settings-docs::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border: 2px solid transparent;
  background-clip: padding-box;
  border-radius: 0;
}

.left-list::-webkit-scrollbar-thumb:hover,
.pdf-view::-webkit-scrollbar-thumb:hover,
.chat-log::-webkit-scrollbar-thumb:hover,
.sessions-list::-webkit-scrollbar-thumb:hover,
.schema-view::-webkit-scrollbar-thumb:hover,
.settings-docs::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.26);
  border: 2px solid transparent;
  background-clip: padding-box;
}

.layout {
  height: 100vh;
  display: grid;
  --left-w: 320px;
  --right-w: 420px;
  --resizer-left-w: 6px;
  --resizer-right-w: 6px;
  grid-template-columns: var(--left-w) var(--resizer-left-w) 1fr var(--resizer-right-w) var(--right-w);
  gap: 0;
}

.layout.left-collapsed {
  --left-w: 0px;
  --resizer-left-w: 0px;
}

.layout.left-collapsed .panel-left,
.layout.left-collapsed .resizer-left {
  visibility: hidden;
  pointer-events: none;
}

.layout.left-collapsed .panel-left {
  border-right: none;
}

.panel {
  height: 100vh;
  overflow: hidden;
  border-right: 1px solid var(--line);
  background: var(--panel);
}

.panel-resizer {
  height: 100vh;
  cursor: col-resize;
  user-select: none;
  position: relative;
  background: transparent;
}

.panel-resizer::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 2px;
  height: 64px;
  transform: translate(-50%, -50%);
  border-radius: 0;
  background: rgba(255, 255, 255, 0.10);
}

.panel-resizer:hover {
  background: rgba(79, 124, 255, 0.10);
}

.panel-resizer:hover::after {
  background: rgba(79, 124, 255, 0.45);
}

.panel-resizer:active {
  background: rgba(79, 124, 255, 0.14);
}

.panel-resizer:active::after {
  background: rgba(79, 124, 255, 0.60);
}

.panel-left {
  grid-column: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.resizer-left {
  grid-column: 2;
}

.resizer-right {
  grid-column: 4;
}

.panel-mid {
  grid-column: 3;
  background: var(--panel2);
  position: relative;
}

.panel-right {
  grid-column: 5;
  border-right: none;
}

.left-top,
.right-top,
.mid-top {
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.left-top {
  flex: 0 0 auto;
  display: grid;
  gap: 12px;
}

.dropzone {
  position: relative;
  border: 1px dashed rgba(255, 255, 255, 0.10);
  border-radius: 0;
  padding: 16px;
  text-align: center;
  cursor: pointer;
  user-select: none;
  background: transparent;
  transition: all var(--transition);
}

.dropzone:hover {
  border-color: rgba(255, 255, 255, 0.20);
  background: rgba(255, 255, 255, 0.02);
}

.upload-status {
  position: absolute;
  inset: 0;
  border-radius: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(17, 19, 26, 0.70);
  backdrop-filter: blur(2px);
}

.upload-spinner {
  width: 18px;
  height: 18px;
  border-radius: 0;
  border: 2px solid rgba(255, 255, 255, 0.55);
  border-right-color: transparent;
  animation: spin 0.8s linear infinite;
}

.upload-status-text {
  font-size: 12px;
  color: var(--text);
}

.dropzone.dragover {
  border-color: var(--primary);
  background: rgba(79, 124, 255, 0.08);
}

.drop-title {
  font-family: var(--font);
  font-weight: 600;
  font-size: 13px;
  color: rgba(255,255,255,0.5);
}

.drop-sub {
  color: rgba(255,255,255,0.25);
  font-size: 11px;
  margin-top: 6px;
}

.left-controls {
  display: grid;
  gap: 8px;
}

.search-input-wrap {
  position: relative;
}

.search-input-wrap .input {
  padding-right: 42px;
}

.search-clear-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border-radius: 0;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  font-size: 18px;
  padding: 0;
}

.search-clear-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.search-clear-btn:active {
  transform: translateY(-50%) scale(0.96);
}

:root[data-theme="light"] .search-clear-btn {
  background: rgba(15, 23, 42, 0.04);
}

:root[data-theme="light"] .search-clear-btn:hover {
  background: rgba(15, 23, 42, 0.08);
}

.left-actions {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
  align-items: center;
  width: 100%;
}

.left-actions .btn {
  padding: 8px 10px;
  border-radius: 0;
  font-size: 12px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.left-actions #btnSettings {
  margin-left: auto;
  font-weight: 650;
  white-space: nowrap;
  flex-shrink: 0;
  text-decoration: none;
}

.input,
.textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 0;
  background: rgba(255, 255, 255, 0.02);
  color: var(--text);
  padding: 10px 14px;
  outline: none;
  font-family: var(--font);
  font-size: 13px;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

select.input {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 34px;
  background-image:
    linear-gradient(45deg, transparent 50%, rgba(255, 255, 255, 0.55) 50%),
    linear-gradient(135deg, rgba(255, 255, 255, 0.55) 50%, transparent 50%);
  background-position:
    calc(100% - 16px) calc(50% - 2px),
    calc(100% - 11px) calc(50% - 2px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

:root[data-theme="light"] select.input {
  background-image:
    linear-gradient(45deg, transparent 50%, rgba(15, 23, 42, 0.60) 50%),
    linear-gradient(135deg, rgba(15, 23, 42, 0.60) 50%, transparent 50%);
}

select.input option {
  background: var(--panel);
  color: var(--text);
}

.input:focus,
.textarea:focus {
  border-color: rgba(255, 255, 255, 0.20);
  background: rgba(255, 255, 255, 0.04);
}

.textarea {
  resize: none;
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.55;
}

.btn {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  padding: 8px 14px;
  border-radius: 0;
  cursor: pointer;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
  transition: all var(--transition);
  user-select: none;
}

a.btn {
  text-decoration: none;
}

a.btn:hover {
  text-decoration: none;
}

.icon-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
}

.btn:hover {
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.05);
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
  font-weight: 600;
}

.btn-primary:hover {
  opacity: 0.85;
}

.btn-danger {
  border-color: rgba(239, 68, 68, 0.35);
  color: var(--danger);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.50);
}

.left-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-gutter: stable;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.left-list > * {
  flex: 0 0 auto;
}

.cat-group {
  border: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  overflow: hidden;
  border-left: 3px solid var(--cat-color, rgba(255,255,255,0.12));
}

.cat-group[open] {
  background: rgba(255, 255, 255, 0.015);
}

.cat-summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  font-family: var(--font);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.01em;
  color: var(--text);
}

.cat-summary::-webkit-details-marker {
  display: none;
}

.cat-summary .cat-left {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.cat-summary .cat-ck {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 0;
  background: rgba(255, 255, 255, 0.02);
  transition: all 0.2s ease;
}

.cat-summary .cat-ck:hover {
  border-color: rgba(79, 124, 255, 0.55);
  background: rgba(79, 124, 255, 0.08);
}

.cat-summary .cat-ckbox {
  width: 12px;
  height: 12px;
  margin: 0;
  accent-color: var(--primary);
}

.cat-summary .cat-ckbox:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.cat-summary .cat-right {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.cat-summary .cat-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.cat-summary .cat-icon {
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.85;
}

.cat-summary .cat-icon svg {
  width: 16px;
  height: 16px;
  fill: rgba(79, 124, 255, 0.10);
  stroke: rgba(215, 225, 255, 0.78);
}

.cat-group[open] .cat-summary .cat-icon svg {
  fill: rgba(79, 124, 255, 0.16);
  stroke: rgba(170, 195, 255, 0.92);
}

.cat-summary .cat-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cat-summary .cat-count {
  font-size: 12px;
  color: var(--muted);
}

.cat-summary .cat-chevron {
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.55;
  transition: transform 0.15s ease;
}

.cat-summary .cat-chevron svg {
  width: 16px;
  height: 16px;
  stroke: rgba(255, 255, 255, 0.65);
}

:root[data-theme="light"] .cat-summary .cat-chevron {
  opacity: 0.75;
}

:root[data-theme="light"] .cat-summary .cat-chevron svg {
  stroke: rgba(15, 23, 42, 0.60);
}

.cat-group[open] .cat-summary .cat-chevron {
  transform: rotate(90deg);
}

.cat-body {
  padding: 0 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cat-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.settings-page .cat-summary {
  padding: 8px 10px;
}

.settings-page .cat-body {
  gap: 8px;
}

.settings-page .doc-item {
  height: auto;
  padding: 8px;
}

.settings-page .actions .btn {
  height: 32px;
  padding: 0 10px;
  font-size: 12px;
}

.settings-page .cat-actions .btn {
  height: 28px;
  width: auto;
  padding: 0 6px;
  font-size: 15px;
  background: transparent;
  border: none;
  opacity: 0.55;
  transition: opacity 0.15s ease;
  cursor: pointer;
}
.settings-page .cat-actions .btn:hover {
  opacity: 1;
  background: transparent;
  border: none;
}
.settings-page .cat-actions .btn.btn-danger {
  font-size: 17px;
}

.settings-page .doc-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  flex-shrink: 0;
}

.settings-page .doc-actions .btn {
  height: 28px;
  width: auto;
  padding: 0 6px;
  font-size: 15px;
  white-space: nowrap;
  background: transparent;
  border: none;
  opacity: 0.55;
  transition: opacity 0.15s ease;
  cursor: pointer;
}
.settings-page .doc-actions .btn:hover {
  opacity: 1;
  background: transparent;
  border: none;
}

.settings-page select.doc-move-select {
  width: 160px;
  min-width: 140px;
  height: 28px;
  padding: 0 30px 0 10px;
  border-radius: 0;
  border: 1px solid var(--line);
  background-color: rgba(255, 255, 255, 0.03);
  color: var(--text);
  outline: none;
  font-size: 12px;
  appearance: none;
  -webkit-appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, rgba(255, 255, 255, 0.55) 50%),
    linear-gradient(135deg, rgba(255, 255, 255, 0.55) 50%, transparent 50%);
  background-position:
    calc(100% - 14px) calc(50% - 2px),
    calc(100% - 9px) calc(50% - 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.settings-page select.doc-move-select option {
  background: var(--panel);
  color: var(--text);
}

:root[data-theme="light"] .settings-page select.doc-move-select {
  background-color: rgba(15, 23, 42, 0.04);
  background-image:
    linear-gradient(45deg, transparent 50%, rgba(15, 23, 42, 0.60) 50%),
    linear-gradient(135deg, rgba(15, 23, 42, 0.60) 50%, transparent 50%);
  background-position:
    calc(100% - 14px) calc(50% - 2px),
    calc(100% - 9px) calc(50% - 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.settings-page select.doc-move-select:focus {
  border-color: rgba(79, 124, 255, 0.55);
  box-shadow: 0 0 0 3px rgba(79, 124, 255, 0.12);
}

.settings-page .doc-sub {
  font-size: 11px;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}

.doc-item {
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 10px 12px;
  background: transparent;
  height: auto;
  overflow: hidden;
  transition: all var(--transition);
}

.doc-item:hover {
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.025);
}

.doc-card {
  position: relative;
  height: auto;
  display: grid;
  grid-template-columns: 1fr 38px;
  gap: 8px;
}

.doc-corner {
  position: absolute;
  top: 2px;
  right: 30px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.doc-side .ck-wrap {
  width: 24px;
  height: 24px;
  margin-top: -2px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 0;
  background: rgba(255, 255, 255, 0.02);
  cursor: pointer;
  transition: all 0.2s ease;
}

.doc-side .ck-wrap:hover {
  border-color: rgba(79, 124, 255, 0.55);
  background: rgba(79, 124, 255, 0.08);
}

.doc-side .ck-wrap.checked {
  border-color: rgba(79, 124, 255, 0.65);
  background: rgba(79, 124, 255, 0.14);
  box-shadow: 0 0 0 3px rgba(79, 124, 255, 0.10);
}

.doc-side .ck-wrap input[type="checkbox"] {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--primary);
}

.doc-main {
  min-width: 0;
  display: grid;
  gap: 6px;
  align-content: start;
}

.doc-title {
  font-family: var(--font);
  font-weight: 600;
  line-height: 1.3;
  font-size: 13px;
  color: rgba(255,255,255,0.90);
}

.doc-sub {
  color: rgba(255,255,255,0.50);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.45;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
}

.doc-side {
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: flex-end;
  padding-top: 0px;
}

.doc-side .icon-btn {
  width: 24px;
  height: 24px;
  font-size: 14px;
  border-radius: 0;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 0;
  border: 1px solid var(--line);
  color: var(--muted);
}

.badge.ready {
  color: rgba(120, 255, 170, 0.9);
  border-color: rgba(120, 255, 170, 0.25);
}

.badge.processing {
  color: rgba(255, 210, 120, 0.9);
  border-color: rgba(255, 210, 120, 0.25);
}

.badge.indexing {
  color: rgba(255, 210, 120, 0.9);
  border-color: rgba(255, 210, 120, 0.25);
}

.badge.processing::before,
.badge.indexing::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 0;
  border: 2px solid currentColor;
  border-right-color: transparent;
  animation: spin 0.8s linear infinite;
}

.badge.deleted {
  color: rgba(255, 120, 120, 0.9);
  border-color: rgba(255, 120, 120, 0.25);
}

/* Right layout - sessions panel */
.right-layout {
  height: 100vh;
  display: grid;
  grid-template-columns: 1fr 200px;
}

.right-layout.sessions-collapsed {
  grid-template-columns: 1fr 0;
}

.right-layout.sessions-collapsed .chat-sessions {
  display: none;
}

.chat-sessions {
  border-left: 1px solid var(--line);
  height: 100vh;
  overflow: hidden;
  display: grid;
  grid-template-rows: 1fr;
}

.sessions-list {
  overflow: auto;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.session-item {
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 0 10px;
  height: 36px;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  transition: all var(--transition);
}

.session-item:hover {
  background: rgba(255, 255, 255, 0.03);
}

.session-item.active {
  border-color: rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.04);
}

.session-item .st {
  font-weight: 650;
  font-size: 12px;
  line-height: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-kebab {
  width: 28px;
  height: 28px;
  font-size: 18px;
  border-radius: 0;
}

.session-menu {
  position: fixed;
  z-index: 2000;
  min-width: 140px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: rgba(17, 19, 26, 0.92);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.38);
  padding: 6px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.session-menu-item {
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  padding: 8px 10px;
  border-radius: 0;
  cursor: pointer;
  font-size: 12px;
}

.session-menu-item:hover {
  border-color: rgba(255, 255, 255, 0.10);
  background: rgba(255, 255, 255, 0.03);
}

.session-menu-item.danger {
  color: rgba(255, 120, 120, 0.95);
}

.chat-main {
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}

.chat-jumpback-btn {
  position: absolute;
  right: 16px;
  bottom: 88px;
  z-index: 60;
  height: 30px;
  padding: 0 12px;
  border-radius: 0;
  font-size: 12px;
  color: var(--text);
  border: 1px solid rgba(79, 124, 255, 0.28);
  background: rgba(79, 124, 255, 0.12);
}

.chat-jumpback-btn:hover {
  border-color: rgba(79, 124, 255, 0.45);
  background: rgba(79, 124, 255, 0.18);
}

/* Enhanced Chat Context Line Dropdown */
.context-dropdown-container {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.context-dropdown-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 4px 8px;
  border-radius: 0;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.context-dropdown-button:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.15);
}

.context-dropdown-button::after {
  content: "▼";
  font-size: 8px;
  margin-left: 6px;
  transition: transform 0.2s ease;
}

.context-dropdown-button.open::after {
  transform: rotate(180deg);
}

.context-dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 4px;
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--panel);
  z-index: 1000;
  padding: 6px 0;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.context-dropdown-menu.hidden {
  display: none;
}

/* --- Welcome / Auth UI (add-on) --- */
/* Agreements (login) */
#agreementsGroup { font-size: 12px; color: var(--muted); }
#agreementsGroup label { line-height: 1.2; }
#agreementsGroup label span { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
#agreementsGroup a { color: var(--text); text-decoration: none; border-bottom: 1px dashed rgba(79,124,255,0.45); padding: 0 2px; border-radius: 0; transition: all .15s ease; }
#agreementsGroup a:hover { background: rgba(79,124,255,0.12); border-bottom-color: rgba(79,124,255,0.80); }
:root[data-theme="light"] #agreementsGroup a { border-bottom-color: rgba(37,99,235,0.45); }
:root[data-theme="light"] #agreementsGroup a:hover { background: rgba(37,99,235,0.10); border-bottom-color: rgba(37,99,235,0.75); }
.overlay {
  position: fixed;
  inset: 0;
  z-index: 5000;
  justify-content: center;
  align-items: center;
  color: #fff;
  background: #101114;
  overflow-y: auto;
  overflow-x: hidden;
}

.overlay:not(.hidden) {
  display: flex;
}

.welcome-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.welcome-bg .grid {
  position: absolute;
  inset: -2px;
  background-image:
    linear-gradient(rgba(255,255,255,0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.06) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(60% 55% at 50% 40%, rgba(0,0,0,0.9), transparent 68%);
  opacity: 0.55;
}

.welcome-bg .blob {
  position: absolute;
  width: 520px;
  height: 520px;
  border-radius: 0;
  filter: blur(40px);
  opacity: 0.55;
  transform: translate3d(0,0,0);
  animation: blobFloat 14s ease-in-out infinite;
}

.welcome-bg .blob.b1 {
  left: -140px;
  top: -120px;
  background: radial-gradient(circle at 30% 30%, rgba(110,142,251,0.9), rgba(110,142,251,0.05));
}

.welcome-bg .blob.b2 {
  right: -160px;
  bottom: -180px;
  background: radial-gradient(circle at 30% 30%, rgba(167,119,227,0.85), rgba(167,119,227,0.04));
  animation-delay: -5s;
}

@keyframes blobFloat {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(0, 24px, 0) scale(1.05); }
}

.welcome-content {
  position: relative;
  text-align: center;
  max-width: 880px;
  width: min(880px, 90vw);
  padding: 60px 56px 48px;
}

.welcome-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.40);
  margin-bottom: 24px;
}

.welcome-content h1 {
  font-family: var(--font);
  font-size: clamp(42px, 5vw, 64px);
  font-weight: 800;
  color: #fff;
  line-height: 1.05;
  letter-spacing: -1.5px;
  margin-bottom: 20px;
}

.welcome-content .subtitle {
  font-size: 15px;
  color: rgba(255,255,255,0.45);
  line-height: 1.7;
  max-width: 460px;
  margin: 0 auto 48px;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  margin: 0 0 48px;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 0;
  overflow: hidden;
}

@media (max-width: 820px) {
  .features-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.feature-card {
  background: rgba(255, 255, 255, 0.02);
  padding: 28px 24px 24px;
  transition: background 0.3s ease;
}

.feature-card:hover {
  background: rgba(255, 255, 255, 0.05);
}

.feature-card .icon {
  font-size: 1.4rem;
  margin-bottom: 16px;
  opacity: 0.7;
}

.feature-card h3 {
  font-family: var(--font);
  font-size: 13px;
  font-weight: 700;
  margin: 0 0 8px;
  color: rgba(255,255,255,0.90);
  letter-spacing: 0.01em;
}

.feature-card p {
  font-size: 12px;
  color: rgba(255,255,255,0.38);
  line-height: 1.6;
  margin: 0;
}

.welcome-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.welcome-note {
  font-size: 11px;
  color: rgba(255,255,255,0.30);
  letter-spacing: 0.5px;
}

.cta-button {
  display: inline-block;
  background: #fff;
  color: #111;
  border: 1px solid #fff;
  padding: 14px 40px;
  border-radius: 0;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.25s ease;
}

.cta-button:hover {
  background: transparent;
  color: #fff;
}

.cta-button:active {
  transform: scale(0.98);
}

.welcome-footer {
  margin-top: 56px;
  font-size: 11px;
  color: rgba(255,255,255,0.22);
  letter-spacing: 0.5px;
}

.welcome-footer a {
  color: rgba(255,255,255,0.55);
  margin: 0 10px;
  text-decoration: none;
}

.welcome-footer a:hover {
  color: #fff;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  z-index: 6000;
  display: none;
  justify-content: center;
  align-items: center;
  color: var(--text);
}

.modal .modal-content {
  position: relative;
}

.close-modal {
  position: absolute;
  top: 14px;
  right: 14px;
  font-size: 22px;
  line-height: 22px;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.7);
}

.close-modal:hover {
  color: #fff;
}

.login-box {
  background: var(--panel);
  padding: 36px;
  border-radius: 0;
  width: min(380px, 90vw);
  text-align: center;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--line);
}

.login-box h2 {
  color: var(--text);
  margin: 0 0 6px;
  font-family: var(--font);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.login-box p {
  color: var(--muted);
  margin: 0 0 24px;
  font-size: 12px;
  letter-spacing: 0.3px;
}

.input-group {
  margin-bottom: 14px;
  display: flex;
  gap: 10px;
}

.input-group input {
  flex: 1;
  padding: 11px 14px;
  border-radius: 0;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: all var(--transition);
}

.input-group input:focus {
  border-color: rgba(124, 156, 255, 0.45);
  box-shadow: 0 0 0 3px rgba(124, 156, 255, 0.10);
  background: rgba(255, 255, 255, 0.06);
}

.input-group input::placeholder {
  color: rgba(255, 255, 255, 0.28);
}

.input-group button {
  padding: 11px 16px;
  border-radius: 0;
  border: 1px solid rgba(255, 255, 255, 0.10);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all var(--transition);
  white-space: nowrap;
}

.input-group button:hover {
  background: rgba(255, 255, 255, 0.10);
  border-color: rgba(255, 255, 255, 0.15);
}

.input-group button.primary-btn {
  background: linear-gradient(135deg, rgba(124, 156, 255, 0.22), rgba(167, 139, 250, 0.18));
  border-color: rgba(124, 156, 255, 0.30);
  width: 100%;
  font-weight: 600;
}

.input-group button.primary-btn:hover {
  background: linear-gradient(135deg, rgba(124, 156, 255, 0.30), rgba(167, 139, 250, 0.25));
  box-shadow: 0 4px 16px rgba(124, 156, 255, 0.18);
}

.msg {
  color: rgba(255, 120, 120, 0.95);
  font-size: 0.9rem;
  margin-top: 8px;
}

.msg:empty {
  display: none;
}

#loginMsg {
  position: static;
  width: 100%;
  max-width: 100%;
  min-height: 0;
  box-sizing: border-box;
  padding: 10px 12px;
  border-radius: 0;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  text-align: center;
  line-height: 1.4;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
}

a.icon-btn {
  text-decoration: none;
}

.context-dropdown-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  line-height: 1.2;
  font-size: 12px;
  color: var(--text);
  cursor: default;
  border-bottom: 1px solid var(--line);
  transition: background-color 0.2s ease;
}

.context-dropdown-item:last-child {
  border-bottom: none;
}

.context-dropdown-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

.context-doc-title {
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 8px;
  color: var(--text);
  font-weight: 500;
  line-height: 1.2;
}

.context-delete-btn {
  width: 18px;
  height: 18px;
  border-radius: 0;
  background: rgba(255, 77, 77, 0.12);
  border: 1px solid rgba(255, 77, 77, 0.35);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  padding: 0;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.context-delete-btn:hover {
  background: rgba(255, 77, 77, 0.20);
  border-color: rgba(255, 77, 77, 0.45);
  transform: scale(1.1);
}

.context-delete-btn:active {
  transform: scale(0.95);
}

/* Other existing styles remain the same */
.mid-meta {
  color: var(--muted);
  font-size: 12px;
}
.mid-meta:empty {
  display: none;
}

.mid-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mid-tabs {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex: 1;
  padding: 4px 0;
}

.tab-btn {
  padding: 5px 14px;
  border-radius: 0;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}

.tab-btn.active {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
  font-weight: 600;
}

.mid-hint {
  margin-left: auto;
  font-size: 10px;
  color: rgba(255,255,255,0.25);
  letter-spacing: 0.5px;
  transform: translateY(14px);
}

.mid-body {
  height: calc(100vh - 58px);
  overflow: hidden;
}

.zoom-controls {
  position: absolute;
  right: 12px;
  top: 130px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 50;
}

.zoom-controls .zoom-btn {
  width: 36px;
  height: 36px;
  border-radius: 0;
  background: rgba(17, 19, 26, 0.55);
  border-color: rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(4px);
}

.pdf-view {
  height: 100%;
  overflow: auto;
  padding: 14px;
}

.page {
  position: relative;
  margin: 0 auto 16px auto;
  width: fit-content;
  border-radius: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #fff;
}

.page canvas {
  display: block;
  position: relative;
  z-index: 1;
}

.pdf-view {
  cursor: grab;
}

.pdf-view:active {
  cursor: grabbing;
}

.textLayer {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: auto;
  user-select: none;
}

.textLayer span {
  color: transparent;
}

.rect-select {
  position: fixed;
  z-index: 1600;
  border: 1px solid rgba(79, 124, 255, 0.55);
  background: rgba(79, 124, 255, 0.12);
  border-radius: 0;
  pointer-events: none;
}

.hl {
  position: absolute;
  z-index: 3;
  border: 2px solid rgba(255, 210, 120, 0.9);
  background: rgba(255, 210, 120, 0.18);
  border-radius: 0;
  pointer-events: none;
}

.schema-view {
  height: 100%;
  overflow: auto;
  padding: 12px 14px;
}

.schema-pre {
  margin: 0;
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.insp-view {
  height: 100%;
  overflow: auto;
  padding: 12px 14px;
}

.insp-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.insp-empty {
  border: 1px dashed var(--line);
  border-radius: 0;
  padding: 12px;
  color: var(--muted);
  font-size: 12px;
}

.insp-card {
  border: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  padding: 10px 12px;
}

.insp-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.insp-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 0;
  border: 1px solid var(--line);
  color: var(--muted);
}

.insp-badge.pdf {
  border-color: rgba(79, 124, 255, 0.35);
  color: rgba(179, 195, 255, 0.95);
}

.insp-badge.chat {
  border-color: rgba(255, 210, 120, 0.30);
  color: rgba(255, 210, 120, 0.95);
}

.insp-actions {
  display: flex;
  gap: 8px;
}

.insp-quote {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 13px;
  line-height: 1.5;
  padding: 8px 10px;
  border-radius: 0;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.12);
}

.insp-note {
  margin-top: 10px;
  width: 100%;
  min-height: 58px;
  resize: vertical;
  padding: 8px 10px;
  border-radius: 0;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  color: var(--text);
  outline: none;
  font-size: 12px;
  line-height: 1.45;
}

.hidden {
  display: none;
}

.session-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.session-title {
  font-family: var(--font);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.3px;
}

.toggles {
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}

.toggle {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  user-select: none;
}

.chat-log {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-log > * {
  flex: 0 0 auto;
}

.msg {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 12px 14px 30px 14px;
  background: rgba(255, 255, 255, 0.02);
  width: fit-content;
  max-width: 92%;
  min-height: 44px;
  color: var(--text);
}

.msg.user {
  align-self: flex-end;
  border-color: rgba(255, 255, 255, 0.10);
  background: rgba(255, 255, 255, 0.04);
  min-width: 140px;
}

.msg.assistant {
  align-self: flex-start;
  border-color: var(--line);
  background: transparent;
}

.msg.pending {
  min-width: 120px;
}

.msg.pending .msg-body {
  min-height: 28px;
}

.msg-thinking {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 0;
}

.thinking-dot {
  width: 6px;
  height: 6px;
  border-radius: 0;
  background: var(--muted);
  animation: thinkingBounce 1.2s ease-in-out infinite;
}

.thinking-dot:nth-child(2) { animation-delay: 0.15s; }
.thinking-dot:nth-child(3) { animation-delay: 0.3s; }

.thinking-text {
  margin-left: 6px;
  font-size: 13px;
  color: var(--muted);
}

@keyframes thinkingBounce {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-4px); }
}

.msg-time {
  position: absolute;
  right: 10px;
  bottom: 8px;
  color: rgba(154, 163, 178, 0.85);
  font-size: 11px;
  line-height: 1;
}

.msg-insp-btn {
  position: absolute;
  right: 58px;
  bottom: 6px;
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 0;
  font-size: 14px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.20);
  border: none;
  background: transparent;
  transition: color 0.15s ease;
}

.msg-insp-btn::after {
  content: attr(data-tip);
  position: absolute;
  right: 0;
  bottom: 34px;
  padding: 6px 8px;
  border-radius: 0;
  font-size: 12px;
  color: var(--text);
  border: 1px solid var(--line);
  background: rgba(17, 19, 26, 0.96);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.35);
  opacity: 0;
  transform: translateY(4px);
  pointer-events: none;
  white-space: nowrap;
}

.msg-insp-btn:hover {
  color: rgba(255, 255, 255, 0.70);
}

.msg-insp-btn:hover::after {
  opacity: 1;
  transform: translateY(0);
}

.msg-insp-btn:active {
  transform: scale(0.96);
}

.msg-insp-btn.saved {
  color: rgba(255, 255, 255, 0.70);
}

:root[data-theme="light"] .msg-insp-btn {
  color: rgba(0, 0, 0, 0.18);
}

:root[data-theme="light"] .msg-insp-btn:hover {
  color: rgba(0, 0, 0, 0.55);
}

:root[data-theme="light"] .msg-insp-btn::after {
  background: rgba(255, 255, 255, 0.96);
  border-color: rgba(15, 23, 42, 0.12);
  box-shadow: 0 12px 34px rgba(2, 6, 23, 0.14);
}

:root[data-theme="light"] .msg-time {
  color: rgba(51, 65, 85, 0.85);
}

:root[data-theme="light"] .doc-title { color: rgba(0,0,0,0.88); }
:root[data-theme="light"] .doc-sub { color: rgba(0,0,0,0.50); }
:root[data-theme="light"] .msg-body { color: rgba(0,0,0,0.82); }
:root[data-theme="light"] .drop-title { color: rgba(0,0,0,0.45); }
:root[data-theme="light"] .drop-sub { color: rgba(0,0,0,0.30); }
:root[data-theme="light"] .mid-hint { color: rgba(0,0,0,0.30); }
:root[data-theme="light"] .cat-group { border-left-color: var(--cat-color, rgba(0,0,0,0.10)); }
:root[data-theme="light"] .doc-item:hover { border-color: rgba(0,0,0,0.12); background: rgba(0,0,0,0.02); }
:root[data-theme="light"] .session-item:hover { background: rgba(0,0,0,0.03); }
:root[data-theme="light"] .session-item.active { border-color: rgba(0,0,0,0.15); background: rgba(0,0,0,0.04); }

.msg-body {
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.6;
  padding-top: 0;
  font-family: var(--font);
  font-size: 13px;
  color: rgba(255,255,255,0.82);
}

.msg-body * {
  color: inherit;
}

.msg-body .md-hr {
  height: 1px;
  background: rgba(255, 255, 255, 0.10);
  margin: 10px 0;
}

.msg-body .md-h2 {
  font-weight: 750;
  font-size: 14px;
  margin: 8px 0 6px 0;
}

.msg-body .md-h3 {
  font-weight: 700;
  font-size: 13px;
  margin: 8px 0 6px 0;
}

.msg-body .md-p {
  margin: 6px 0;
}

.msg-body ol,
.msg-body ul {
  margin: 6px 0 6px 18px;
  padding: 0;
}

.msg-body li {
  margin: 4px 0;
}

.cite {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 18px;
  padding: 0 6px;
  border-radius: 0;
  border: 1px solid rgba(79, 124, 255, 0.35);
  background: rgba(79, 124, 255, 0.14);
  color: var(--text);
  cursor: pointer;
  margin: 0 2px;
  font-size: 12px;
}

.chat-input {
  border-top: 1px solid var(--line);
  padding: 12px;
}

.chat-input-wrap {
  position: relative;
}

.chat-input-wrap .textarea {
  padding-right: 54px;
  padding-bottom: 18px;
}

.send-btn {
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 34px;
  height: 34px;
  border-radius: 0;
  font-size: 16px;
}

.tooltip {
  position: fixed;
  z-index: 1000;
  max-width: 520px;
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 10px 12px;
  background: rgba(17, 19, 26, 0.96);
  color: var(--text);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  font-size: 12px;
  line-height: 1.4;
}

.translation-popup {
  position: fixed;
  z-index: 1500;
  max-width: min(520px, calc(100vw - 24px));
  border: 1px solid rgba(79, 124, 255, 0.28);
  border-radius: 0;
  padding: 10px 12px;
  background: rgba(17, 19, 26, 0.96);
  color: var(--text);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  font-size: 12px;
  line-height: 1.45;
}

.sel-menu { display: flex; gap: 8px; flex-wrap: wrap; }
.sel-menu .btn { height: 28px; font-size: 12px; padding: 0 10px; }

/* ─── Paper Recommendation (Social) ─── */
.rec-badge {
  position: absolute;
  top: 2px; right: 2px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #e53935;
}
.rec-badge.hidden { display: none; }
.nav-badge {
  position: absolute;
  top: 4px; right: 4px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #e53935;
}
.nav-badge.hidden { display: none; }
.rec-inbox {
  position: fixed;
  top: 60px; left: 50%;
  transform: translateX(-50%);
  width: min(520px, 92vw);
  max-height: 70vh;
  overflow-y: auto;
  z-index: 1500;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 8px 32px rgba(0,0,0,0.35);
  padding: 16px;
}
.rec-inbox-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.rec-inbox-item {
  border: 1px solid var(--line);
  padding: 10px 12px;
  margin-bottom: 8px;
  font-size: 12px;
}
.rec-inbox-item .rec-from { color: var(--primary-accent); font-weight: 600; }
.rec-inbox-item .rec-title { font-weight: 600; margin: 4px 0; color: var(--text); }
.rec-inbox-item .rec-msg { color: var(--muted); margin-bottom: 6px; font-style: italic; }
.rec-inbox-item .rec-actions { display: flex; gap: 6px; }
.rec-inbox-item .rec-actions .btn { height: 26px; font-size: 11px; padding: 0 10px; }
.rec-inbox-overlay {
  position: fixed;
  inset: 0;
  z-index: 1499;
  background: rgba(0,0,0,0.3);
}
.rec-send-modal {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: min(400px, 90vw);
  z-index: 1600;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 8px 32px rgba(0,0,0,0.35);
  padding: 20px;
}
.rec-send-modal h3 { margin: 0 0 12px; font-size: 14px; color: var(--text); }
.rec-send-modal select, .rec-send-modal textarea { width: 100%; margin-bottom: 10px; }
.rec-send-modal .rec-send-actions { display: flex; gap: 8px; justify-content: flex-end; }
.rec-send-overlay {
  position: fixed;
  inset: 0;
  z-index: 1599;
  background: rgba(0,0,0,0.3);
}

/* ─── Friends (settings page) ─── */
.friend-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border: 1px solid var(--line);
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--text);
}
.friend-item .btn { height: 26px; font-size: 11px; padding: 0 10px; }
.friend-request {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border: 1px solid var(--line);
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--text);
}
.friend-request .fr-actions { display: flex; gap: 6px; }
.friend-request .btn { height: 26px; font-size: 11px; padding: 0 10px; }
.friend-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  overflow: hidden;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--line);
}

/* ─── Profile Section ─── */
.profile-section {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}
.profile-avatar-wrap {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.profile-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--line);
  background: rgba(255,255,255,0.04);
}
.profile-fields {
  flex: 1;
  min-width: 0;
}

/* ─── Collaboration Groups ─── */
.group-list { display: grid; gap: 10px; }
.group-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
  background: rgba(255,255,255,0.02);
  transition: border-color 0.15s ease, background 0.15s ease;
}
.group-item:hover {
  border-color: rgba(124,156,255,0.22);
  background: rgba(255,255,255,0.04);
}
.group-item-info { flex: 1; min-width: 0; }
.group-item-name { font-weight: 650; font-size: 13px; }
.group-item-meta { font-size: 11px; color: var(--muted); margin-top: 2px; }
.group-item-actions { display: flex; gap: 6px; flex-shrink: 0; }

.group-detail-header {
  display: flex; align-items: center; gap: 10px; margin-bottom: 14px;
}
.group-detail-name { font-weight: 800; font-size: 15px; flex: 1; }
.group-detail-actions { display: flex; gap: 6px; }

.group-section-title {
  font-weight: 650; font-size: 13px; margin: 14px 0 8px;
  display: flex; align-items: center;
}

.group-members { display: grid; gap: 6px; }
.group-member-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 12px; background: rgba(255,255,255,0.02);
}
.group-role-tag {
  display: inline-block; font-size: 10px; padding: 1px 6px; border-radius: 999px;
  background: rgba(167,139,250,0.15); color: var(--primary-accent);
  margin-left: 4px; vertical-align: middle;
}

.group-papers { display: grid; gap: 8px; }
.group-paper-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: rgba(255,255,255,0.02);
}
.group-paper-info { flex: 1; min-width: 0; }
.group-paper-title {
  font-weight: 600; font-size: 13px; line-height: 1.35;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.group-paper-meta { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* ─── Group switcher in workspace ─── */
.group-switcher {
  display: flex; align-items: center; gap: 6px; padding: 6px 10px;
  border-bottom: 1px solid var(--line); font-size: 12px;
}
.group-switcher select {
  flex: 1; min-width: 0;
  padding: 4px 8px; border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--panel); color: var(--text);
  font-size: 12px; font-family: var(--font);
}

/* ── Discussion Threads ──────────────────────────────────────────────── */
.disc-list { display:flex; flex-direction:column; gap:6px; }
.disc-item {
  display:flex; align-items:center; gap:10px;
  padding:10px 12px; border:1px solid var(--line);
  border-radius:8px; background:var(--panel);
}
.disc-thread {
  display:flex; flex-direction:column; gap:2px;
  max-height:50vh; overflow-y:auto; padding:4px 0;
  margin-bottom:8px;
}
.disc-msg {
  padding:8px 12px; border-radius:8px;
  background:var(--panel); border:1px solid var(--line);
}
.disc-msg-author {
  font-size:12px; font-weight:600; color:var(--text);
  margin-bottom:2px;
}
.disc-msg-content {
  font-size:13px; color:var(--text);
  white-space:pre-wrap; word-break:break-word;
}
.disc-input-bar {
  display:flex; align-items:center; gap:8px;
  padding:8px 0; border-top:1px solid var(--line);
  margin-top:4px;
}

/* ─── Draft Editor ─── */
.draft-container {
  display: flex;
  gap: 1px;
  height: 60vh;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  margin-top: 8px;
  background: var(--line);
}
.draft-editor-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  min-width: 0;
}
.draft-editor-pane textarea {
  width: 100%;
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  padding: 16px;
  font-size: 13px;
  line-height: 1.7;
  font-family: "Cascadia Code", "Fira Code", "JetBrains Mono", monospace;
  background: transparent;
  color: var(--text);
  tab-size: 2;
}
.draft-toolbar {
  display: flex;
  gap: 6px;
  margin-left: 12px;
}
.draft-tabs {
  display: flex;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.draft-tab {
  padding: 6px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
}
.draft-tab:hover { color: var(--text); }
.draft-tab.active {
  color: var(--primary-accent);
  border-bottom-color: var(--primary-accent);
}
.draft-tab-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}
.draft-papers-list {
  overflow-y: auto;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.08) transparent;
}
.draft-paper-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  background: var(--panel2);
}
.draft-paper-title {
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
  user-select: none;
  line-height: 1.5;
}
.draft-paper-title:hover { color: var(--primary-accent); }
.draft-paper-summary {
  padding-left: 12px;
  border-left: 2px solid var(--line);
  margin-top: 4px;
}
.draft-preview-pane {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text);
  background: var(--panel2);
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.08) transparent;
}
.draft-preview-pane h1 { font-size: 1.6em; font-weight: 700; margin: 0.6em 0 0.4em; border-bottom: 1px solid var(--line); padding-bottom: 0.3em; }
.draft-preview-pane h2 { font-size: 1.3em; font-weight: 700; margin: 0.5em 0 0.3em; }
.draft-preview-pane h3 { font-size: 1.1em; font-weight: 600; margin: 0.4em 0 0.2em; }
.draft-preview-pane p { margin: 0.5em 0; }
.draft-preview-pane code {
  background: rgba(255,255,255,0.06);
  padding: 2px 5px;
  border-radius: 4px;
  font-family: "Cascadia Code", "Fira Code", monospace;
  font-size: 0.9em;
}
.draft-preview-pane pre {
  background: rgba(0,0,0,0.3);
  padding: 12px;
  border-radius: 6px;
  overflow-x: auto;
  margin: 0.5em 0;
}
.draft-preview-pane pre code {
  background: transparent;
  padding: 0;
  border-radius: 0;
}
.draft-preview-pane blockquote {
  border-left: 3px solid var(--primary-accent);
  padding: 4px 12px;
  margin: 0.5em 0;
  color: var(--muted);
}
.draft-preview-pane ul, .draft-preview-pane ol { padding-left: 1.5em; margin: 0.5em 0; }
.draft-preview-pane li { margin: 0.2em 0; }
.draft-preview-pane hr { border: none; border-top: 1px solid var(--line); margin: 1em 0; }
.draft-preview-pane a { color: var(--primary-accent); text-decoration: underline; }
.draft-status-bar {
  font-size: 11px;
  color: var(--muted);
  padding: 6px 0;
  margin-top: 4px;
}
.draft-actions {
  display: flex;
  gap: 6px;
  margin-left: auto;
}
.draft-history-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
  max-height: 60vh;
  overflow-y: auto;
}
.draft-history-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.hidden {
  display: none;
}