:root {
  --bg: #09090b;
  --bg-secondary: #0c0c0f;
  --sidebar: #0c0c0f;
  --card: rgba(22,22,28,0.7);
  --card-hover: rgba(30,30,40,0.8);
  --card-solid: #16161c;
  --border: rgba(255,255,255,0.06);
  --border-hover: rgba(255,255,255,0.12);
  --border-accent: rgba(139,92,246,0.3);
  --text: #f0f0f5;
  --text-secondary: #a1a1aa;
  --text-dim: #52525b;
  --accent: #8b5cf6;
  --accent-hover: #7c3aed;
  --accent-light: #c4b5fd;
  --accent-glow: rgba(139,92,246,0.15);
  --accent-bg: rgba(139,92,246,0.08);
  --green: #34d399;
  --green-bg: rgba(52,211,153,0.08);
  --orange: #fbbf24;
  --orange-bg: rgba(251,191,36,0.08);
  --red: #f87171;
  --red-bg: rgba(248,113,113,0.08);
  --blue: #60a5fa;
  --blue-bg: rgba(96,165,250,0.08);
  --radius: 14px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --shadow-glow: 0 0 40px rgba(139,92,246,0.08);
  --transition: all 0.25s cubic-bezier(0.4,0,0.2,1);
  --font-display: 'Plus Jakarta Sans', 'Noto Sans SC', -apple-system, sans-serif;
  --font-body: 'Plus Jakarta Sans', 'Noto Sans SC', -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
  display: flex;
}

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }

/* ===== Sidebar ===== */
.sidebar {
  width: 240px;
  min-width: 240px;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.sidebar-brand {
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--border);
}

.sidebar-brand h1 {
  font-size: 18px;
  font-weight: 700;
  background: linear-gradient(135deg, #c4b5fd 0%, #60a5fa 50%, #22d3ee 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.3px;
}

.sidebar-brand .subtitle {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 4px;
  letter-spacing: 0.5px;
}

.sidebar-status {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-dim);
}

.status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
  box-shadow: 0 0 8px rgba(52,211,153,0.5);
  animation: pulse 2s infinite;
}
.status-dot.offline { background: var(--red); animation: none; }
@keyframes pulse { 0%,100%{ opacity:1; } 50%{ opacity:0.4; } }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px;
}

.nav-section {
  margin-bottom: 8px;
}

.nav-section-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-dim);
  padding: 8px 10px 6px;
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  transition: var(--transition);
  margin-bottom: 2px;
  border: 1px solid transparent;
  user-select: none;
}

.nav-item:hover {
  background: var(--card);
  color: var(--text);
}

.nav-item.active {
  background: var(--accent-bg);
  color: var(--accent-light);
  border-color: var(--border-accent);
  box-shadow: 0 0 20px rgba(139,92,246,0.06);
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 18px;
  border-radius: 0 4px 4px 0;
  background: var(--accent);
}

.nav-item .icon {
  font-size: 16px;
  width: 22px;
  text-align: center;
  flex-shrink: 0;
}

.nav-item .badge {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  padding: 1px 7px;
  border-radius: 10px;
  font-weight: 600;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

.collect-mode-btn { background: transparent; border: 1px solid transparent; color: var(--text-dim); cursor: pointer; transition: var(--transition); }
.collect-mode-btn:hover { color: var(--text); }
.collect-mode-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ===== Main Content ===== */
.main {
  flex: 1;
  height: 100vh;
  overflow-y: auto;
  background: var(--bg);
}

.page-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(9,9,11,0.8);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border-bottom: 1px solid var(--border);
  padding: 20px 32px 16px;
}

.page-header h2 {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, var(--text) 0%, var(--text-secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.page-header .desc {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 4px;
}

.page-content {
  padding: 24px 32px 48px;
  max-width: 1100px;
}

/* ===== Cards ===== */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  transition: var(--transition);
}
.card:hover { border-color: var(--border-hover); }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent-light);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ===== Stats Grid ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: var(--transition);
}
.stat-card:hover { border-color: var(--border-hover); transform: translateY(-1px); }

.stat-card .stat-icon {
  font-size: 20px;
  margin-bottom: 12px;
}

.stat-card .stat-number {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 800;
  background: linear-gradient(135deg, #c4b5fd 0%, #60a5fa 60%, #22d3ee 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.1;
}

.stat-card .stat-label {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
}

/* ===== Layout Grids ===== */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}

/* ===== Tags ===== */
.tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
  margin-right: 4px;
  margin-bottom: 4px;
}
.tag-ai { background: var(--accent-bg); color: var(--accent-light); border: 1px solid rgba(139,92,246,0.15); }
.tag-product { background: var(--green-bg); color: var(--green); border: 1px solid rgba(52,211,153,0.15); }
.tag-investment { background: var(--orange-bg); color: var(--orange); border: 1px solid rgba(251,191,36,0.15); }
.tag-growth { background: var(--blue-bg); color: var(--blue); border: 1px solid rgba(96,165,250,0.15); }
.tag-default { background: rgba(107,112,148,0.15); color: var(--text-dim); }

/* ===== Buttons ===== */
.btn {
  padding: 9px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-primary { background: linear-gradient(135deg, var(--accent) 0%, #7c3aed 100%); color: #fff; box-shadow: 0 2px 12px rgba(139,92,246,0.25); }
.btn-primary:hover { box-shadow: 0 4px 20px rgba(139,92,246,0.4); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  background: var(--card);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--accent); color: var(--text); }
.btn-secondary.active { border-color: var(--accent); color: var(--accent-light); background: var(--accent-bg); }

.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { opacity: 0.85; }

.btn-small {
  padding: 5px 14px;
  font-size: 12px;
}

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border: none;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 12px;
  transition: var(--transition);
}
.btn-ghost:hover { color: var(--text); }

/* ===== Form Elements ===== */
.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

textarea, input[type="text"], input[type="url"], input[type="password"] {
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: var(--transition);
}

textarea:focus, input[type="text"]:focus, input[type="url"]:focus, input[type="password"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(108,92,231,0.1);
}

/* ===== Input with icon wrapper ===== */
.input-icon-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.input-icon-wrap .input-icon {
  position: absolute;
  left: 14px;
  color: var(--text-dim);
  font-size: 15px;
  pointer-events: none;
  transition: var(--transition);
  display: flex;
  align-items: center;
}
.input-icon-wrap input {
  padding-left: 40px;
}
.input-icon-wrap input:focus ~ .input-icon,
.input-icon-wrap input:focus + .input-icon {
  color: var(--accent);
}
.input-icon-wrap .pwd-toggle {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px 6px;
  font-size: 15px;
  border-radius: 4px;
  transition: var(--transition);
  display: flex;
  align-items: center;
}
.input-icon-wrap .pwd-toggle:hover {
  color: var(--text);
  background: var(--card-hover);
}

textarea { resize: vertical; min-height: 120px; line-height: 1.6; }

.btn-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 6px;
}

/* ===== Search ===== */
.search-container {
  position: relative;
}

.search-input-wrap {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.search-input-wrap input {
  flex: 1;
}

.filter-bar {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

/* ===== Note Items ===== */
.note-list { }

.note-item {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  cursor: pointer;
  border: 1px solid transparent;
  margin-bottom: 4px;
}
.note-item:hover {
  background: var(--card-hover);
  border-color: var(--border);
}

.note-item-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.note-title {
  font-size: 14px;
  font-weight: 500;
  line-height: 1.5;
}

.note-meta {
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 6px;
}

.note-snippet {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 6px;
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.note-score {
  font-size: 10px;
  color: var(--accent-light);
  background: var(--accent-bg);
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
  font-weight: 500;
}

/* ===== Review Items ===== */
.review-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  gap: 16px;
}
.review-item:last-child { border-bottom: none; }

.review-reason {
  font-size: 12px;
  color: var(--orange);
  margin-top: 4px;
}

.review-insight {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 6px;
  line-height: 1.5;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent);
}

/* ===== Deepening Dialogue ===== */
.deepen-panel {
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.deepen-header {
  padding: 10px 14px;
  background: linear-gradient(135deg, var(--accent), #6366f1);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
.deepen-messages {
  max-height: 400px;
  overflow-y: auto;
  padding: 12px;
}
.deepen-msg {
  margin-bottom: 12px;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.6;
  max-width: 85%;
}
.deepen-msg.ai {
  background: var(--bg-secondary);
  border-left: 3px solid var(--accent);
  margin-right: auto;
}
.deepen-msg.user {
  background: var(--accent);
  color: #fff;
  margin-left: auto;
  border-left: none;
}
.deepen-msg .questions {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.deepen-msg .questions li {
  cursor: pointer;
  padding: 4px 0;
  color: var(--accent);
  font-weight: 500;
}
.deepen-msg .questions li:hover {
  text-decoration: underline;
}
.deepen-input-row {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}
.deepen-input-row input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  background: var(--bg-secondary);
  color: var(--text);
}
.deepen-input-row button {
  white-space: nowrap;
}
.review-deepening {
  margin-top: 8px;
  padding: 10px 12px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  border-left: 3px solid #f59e0b;
  font-size: 12px;
  line-height: 1.5;
}
.review-deepening .question {
  color: var(--accent);
  font-weight: 600;
  margin-top: 6px;
}
.review-deepening .contradiction {
  color: #ef4444;
  font-style: italic;
  margin-top: 4px;
}

/* ===== Review Discuss Modal ===== */
.review-discuss-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.review-discuss-modal {
  width: 100%;
  max-width: 640px;
  height: 70vh;
  background: var(--bg);
  border-radius: 16px 16px 0 0;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.3s ease;
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.review-discuss-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.review-discuss-header .title-area {
  flex: 1;
  overflow: hidden;
}
.review-discuss-header .title-area h3 {
  margin: 0;
  font-size: 15px;
  color: var(--text);
}
.review-discuss-header .title-area .subtitle {
  font-size: 12px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.review-discuss-header .actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.review-discuss-header .actions .close-btn {
  font-size: 20px;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px 8px;
}
.review-discuss-header .actions .close-btn:hover { color: var(--text); }
.review-discuss-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 18px;
}
.review-discuss-messages .rd-msg {
  display: flex;
  margin-bottom: 14px;
  align-items: flex-start;
  gap: 10px;
}
.review-discuss-messages .rd-msg.user {
  flex-direction: row-reverse;
}
.review-discuss-messages .rd-msg .avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.review-discuss-messages .rd-msg.assistant .avatar {
  background: var(--accent-bg);
  border: 1px solid rgba(139,92,246,0.15);
}
.review-discuss-messages .rd-msg.user .avatar {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
}
.review-discuss-messages .rd-msg .bubble {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}
.review-discuss-messages .rd-msg.assistant .bubble {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-top-left-radius: 4px;
}
.review-discuss-messages .rd-msg.user .bubble {
  background: linear-gradient(135deg, #8b5cf6, #7c3aed);
  color: #fff;
  border-top-right-radius: 4px;
}
.review-discuss-input-row {
  display: flex;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
  flex-shrink: 0;
}
.review-discuss-input-row input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 13px;
  background: var(--card);
  color: var(--text);
  outline: none;
}
.review-discuss-input-row input:focus {
  border-color: var(--accent);
}
.btn-discuss-trigger {
  font-size: 12px;
  padding: 4px 10px;
  background: linear-gradient(135deg, rgba(139,92,246,0.15), rgba(124,58,237,0.1));
  color: var(--accent);
  border: 1px solid rgba(139,92,246,0.25);
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}
.btn-discuss-trigger:hover {
  background: rgba(139,92,246,0.2);
}

/* ===== Topic Bars ===== */
.topic-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.topic-bar .bar-label {
  width: 60px;
  font-size: 13px;
  text-align: right;
  color: var(--text-secondary);
  flex-shrink: 0;
}
.topic-bar .bar-track {
  flex: 1;
  height: 24px;
  background: var(--bg-secondary);
  border-radius: 12px;
  overflow: hidden;
}
.topic-bar .bar-fill {
  height: 100%;
  border-radius: 12px;
  transition: width 0.6s ease;
  min-width: 6px;
}
.topic-bar .bar-count {
  width: 36px;
  font-size: 13px;
  color: var(--text-dim);
  font-weight: 600;
}

.bar-fill.ai { background: linear-gradient(90deg, #8b5cf6, #a78bfa); }
.bar-fill.product { background: linear-gradient(90deg, #10b981, #34d399); }
.bar-fill.investment { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.bar-fill.growth { background: linear-gradient(90deg, #3b82f6, #60a5fa); }

/* ===== Chat ===== */
.chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 140px);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0 0 16px;
}

.chat-bubble {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: 16px;
  margin-bottom: 12px;
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
}

.chat-bubble.user {
  margin-left: auto;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 12px rgba(139,92,246,0.2);
}

.chat-bubble.ai {
  margin-right: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.chat-bubble .refs {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 12px;
  color: var(--text-dim);
}

.chat-bubble.ai .refs {
  border-top-color: var(--border);
}

.chat-input-area {
  display: flex;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.chat-input-area input {
  flex: 1;
}

/* ===== Detail Panel ===== */
.detail-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 200;
  display: flex;
  justify-content: flex-end;
  animation: fadeIn 0.2s ease;
}

.detail-panel {
  width: 600px;
  max-width: 90vw;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  height: 100vh;
  overflow-y: auto;
  animation: slideLeft 0.25s ease;
  padding: 24px;
}

@keyframes fadeIn { from{opacity:0} to{opacity:1} }
@keyframes slideLeft { from{transform:translateX(100%)} to{transform:translateX(0)} }

.detail-panel .detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
}

.detail-panel .detail-title {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.4;
  flex: 1;
}

.detail-close {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text-dim);
  width: 32px; height: 32px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  margin-left: 12px;
  transition: var(--transition);
}
.detail-close:hover { border-color: var(--accent); color: var(--text); }

.detail-section {
  margin-bottom: 20px;
}

.detail-section h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-light);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.detail-section .content {
  font-size: 14px;
  line-height: 1.8;
  color: var(--text-secondary);
  white-space: pre-wrap;
}

.detail-section .annotation {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 8px;
}

.detail-section .annotation .time {
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 4px;
}

.annotation-form {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.annotation-form input {
  flex: 1;
}

/* ===== Knowledge Browser ===== */
.knowledge-controls {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}

.knowledge-controls select {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 8px 12px;
  font-size: 13px;
  outline: none;
  cursor: pointer;
}

.load-more {
  text-align: center;
  padding: 16px;
}

/* ===== Empty State ===== */
.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-dim);
}
.empty .icon { font-size: 42px; margin-bottom: 14px; }
.empty .text { font-size: 14px; line-height: 1.6; }

/* ===== Toast ===== */
.toast {
  position: fixed;
  top: 24px;
  right: 24px;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  z-index: 999;
  animation: toastIn 0.3s ease;
  max-width: 400px;
  box-shadow: var(--shadow);
}
.toast-success { background: var(--green); color: #fff; }
.toast-error { background: var(--red); color: #fff; }
.toast-info { background: var(--accent); color: #fff; }
@keyframes toastIn { from{transform:translateY(-20px);opacity:0} to{transform:translateY(0);opacity:1} }

/* ===== Loading ===== */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-dim);
}

.spinner {
  display: inline-block;
  width: 28px; height: 28px;
  border: 2.5px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 8px;
}
@keyframes spin { to{transform:rotate(360deg)} }

/* ===== Dialog ===== */
.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  animation: fadeIn 0.2s ease;
}

.dialog {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  max-width: 440px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.dialog h3 {
  font-size: 18px;
  margin-bottom: 8px;
  color: var(--accent-light);
}

.dialog p {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 16px;
  line-height: 1.5;
}

.dialog .dialog-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
}

/* ===== Settings ===== */
.settings-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.settings-item:last-child { border-bottom: none; }
.settings-item .label {
  font-size: 14px;
  font-weight: 500;
}
.settings-item .value {
  font-size: 13px;
  color: var(--text-dim);
  font-family: 'SF Mono', 'Cascadia Code', monospace;
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .sidebar { width: 60px; min-width: 60px; }
  .sidebar-brand h1, .sidebar-brand .subtitle,
  .nav-section-title, .nav-item span:not(.icon),
  .nav-item .badge, .sidebar-footer { display: none; }
  .nav-item { justify-content: center; padding: 10px; }
  .sidebar-status span:not(.status-dot) { display: none; }
  .sidebar-status { justify-content: center; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .page-content { padding: 16px; }
  .page-header { padding: 16px; }
}
/* ===== Auth Overlay ===== */
.auth-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-box {
  background: var(--card);
  border: 1px solid var(--border);
  backdrop-filter: blur(24px);
  border-radius: 24px;
  padding: 44px 40px;
  width: 440px;
  max-width: 92%;
  box-shadow: 0 16px 64px rgba(0,0,0,0.5), var(--shadow-glow);
  position: relative;
  z-index: 1;
  animation: authBoxIn 0.5s cubic-bezier(0.4,0,0.2,1);
}

.auth-box h2 {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 800;
  text-align: center;
  margin-bottom: 6px;
  background: linear-gradient(135deg, var(--accent-light), var(--blue));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.auth-box .auth-subtitle {
  text-align: center;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 28px;
}

.auth-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 24px;
}

.auth-tab {
  flex: 1;
  padding: 9px 0;
  text-align: center;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  background: transparent;
  color: var(--text-dim);
  border: none;
}

.auth-tab.active {
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  color: #fff;
  box-shadow: 0 2px 12px rgba(139,92,246,0.3);
}

.auth-error {
  background: var(--red-bg);
  border: 1px solid rgba(253,121,121,0.3);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  color: var(--red);
  margin-bottom: 14px;
  display: none;
}

/* ===== User Bar ===== */
.user-bar {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--blue));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.user-info {
  flex: 1;
  min-width: 0;
}

.user-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-role {
  font-size: 11px;
  color: var(--text-dim);
}

.user-menu-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 16px;
  padding: 4px;
  transition: var(--transition);
}
.user-menu-btn:hover { color: var(--text); }

.user-menu {
  position: absolute;
  bottom: 60px;
  left: 10px;
  right: 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px;
  box-shadow: var(--shadow);
  z-index: 100;
  display: none;
}

.user-menu.show { display: block; }

.user-menu-item {
  padding: 9px 12px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
}
.user-menu-item:hover { background: var(--card-hover); color: var(--text); }
.user-menu-item.danger { color: var(--red); }
.user-menu-item.danger:hover { background: var(--red-bg); }

/* ===== Admin Table ===== */
.admin-table {
  width: 100%;
  border-collapse: collapse;
}

.admin-table th, .admin-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.admin-table th {
  color: var(--text-dim);
  font-weight: 600;
  font-size: 12px;
}

.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
}

.status-badge.active { background: var(--green-bg); color: var(--green); }
.status-badge.disabled { background: var(--red-bg); color: var(--red); }
.role-badge { color: var(--orange); font-weight: 500; }


/* === Enhanced animations & effects === */
@keyframes authBoxIn { from{opacity:0;transform:translateY(20px) scale(0.97)} to{opacity:1;transform:translateY(0) scale(1)} }
@keyframes authOrb1 { 0%,100%{transform:translate(0,0) scale(1)} 33%{transform:translate(40px,-30px) scale(1.1)} 66%{transform:translate(-20px,20px) scale(0.95)} }
@keyframes authOrb2 { 0%,100%{transform:translate(0,0) scale(1)} 33%{transform:translate(-30px,20px) scale(1.05)} 66%{transform:translate(20px,-40px) scale(0.9)} }
.auth-overlay::before {
  content: '';position: absolute;top: 15%;left: 20%;width: 400px;height: 400px;
  background: radial-gradient(circle, rgba(139,92,246,0.12) 0%, transparent 70%);
  border-radius: 50%;animation: authOrb1 12s ease-in-out infinite;pointer-events: none;
}
.auth-overlay::after {
  content: '';position: absolute;bottom: 10%;right: 15%;width: 350px;height: 350px;
  background: radial-gradient(circle, rgba(96,165,250,0.08) 0%, transparent 70%);
  border-radius: 50%;animation: authOrb2 15s ease-in-out infinite;pointer-events: none;
}
@keyframes staggerIn { from{opacity:0;transform:translateY(12px)} to{opacity:1;transform:translateY(0)} }
.stats-grid .stat-card { animation: staggerIn 0.4s cubic-bezier(0.4,0,0.2,1) both; }
.stats-grid .stat-card:nth-child(1) { animation-delay: 0.05s; }
.stats-grid .stat-card:nth-child(2) { animation-delay: 0.1s; }
.stats-grid .stat-card:nth-child(3) { animation-delay: 0.15s; }
.stats-grid .stat-card:nth-child(4) { animation-delay: 0.2s; }
.grid-2 > .card { animation: staggerIn 0.4s cubic-bezier(0.4,0,0.2,1) both; }
.grid-2 > .card:nth-child(1) { animation-delay: 0.25s; }
.grid-2 > .card:nth-child(2) { animation-delay: 0.3s; }
/* Stat card hover glow line */
.stat-card::before {
  content: '';position: absolute;top: 0;left: 0;right: 0;height: 1px;
  background: linear-gradient(90deg, transparent, rgba(139,92,246,0.3), transparent);
  opacity: 0;transition: opacity 0.3s ease;
}
.stat-card:hover::before { opacity: 1; }
.stat-card { position: relative; overflow: hidden; }
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-glow); }
/* Card glass */
.card { backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.card:hover { box-shadow: var(--shadow-glow); }
/* Detail overlay blur */
.detail-overlay { backdrop-filter: blur(4px); }
/* Note score mono */
.note-score { font-family: var(--font-mono); }
/* Bar count mono */
.topic-bar .bar-count { font-family: var(--font-mono); }
/* Settings value mono */
.settings-item .value { font-family: var(--font-mono); }
/* Nav section title mono */
.nav-section-title { font-family: var(--font-mono); }
/* Sidebar subtitle mono */
.sidebar-brand .subtitle { font-family: var(--font-mono); text-transform: uppercase; letter-spacing: 1.5px; }
/* User avatar rounded square */
.user-avatar { border-radius: 10px !important; }
/* Toast enhanced */
.toast { backdrop-filter: blur(8px); }
.toast-success { background: rgba(52,211,153,0.9); }
.toast-error { background: rgba(248,113,113,0.9); }
.toast-info { background: rgba(139,92,246,0.9); }



/* ============================== */
/* UI Enhancement Layer v2.0       */
/* ============================== */

/* --- Atmospheric Background --- */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 10% 20%, rgba(139,92,246,0.06) 0%, transparent 60%),
    radial-gradient(ellipse 60% 50% at 90% 80%, rgba(96,165,250,0.04) 0%, transparent 50%),
    radial-gradient(ellipse 40% 30% at 50% 10%, rgba(52,211,153,0.03) 0%, transparent 40%);
  pointer-events: none;
  z-index: 0;
}

/* Subtle noise texture overlay */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  opacity: 0.015;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
}

.sidebar, .main, .auth-container { position: relative; z-index: 1; }

/* --- Enhanced Sidebar --- */
.sidebar {
  background: linear-gradient(180deg, #0e0e13 0%, #0a0a0f 100%);
  border-right: 1px solid rgba(255,255,255,0.04);
}

.sidebar-brand h1 {
  font-size: 19px;
  font-weight: 800;
  background: linear-gradient(135deg, #e0d4ff 0%, #8b5cf6 40%, #60a5fa 70%, #22d3ee 100%);
  background-size: 200% 200%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: brandShimmer 8s ease-in-out infinite;
}

@keyframes brandShimmer {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.nav-item {
  position: relative;
  border-radius: 10px;
  transition: all 0.2s cubic-bezier(0.4,0,0.2,1);
}

.nav-item:hover {
  background: rgba(139,92,246,0.06);
  transform: translateX(2px);
}

.nav-item.active {
  background: linear-gradient(135deg, rgba(139,92,246,0.12) 0%, rgba(96,165,250,0.08) 100%);
  border-color: rgba(139,92,246,0.25);
  box-shadow: 0 0 24px rgba(139,92,246,0.08), inset 0 0 12px rgba(139,92,246,0.04);
}

.nav-item.active .icon {
  filter: drop-shadow(0 0 4px rgba(139,92,246,0.4));
}

/* --- Status dot enhanced pulse --- */
.status-dot {
  box-shadow: 0 0 6px rgba(52,211,153,0.4), 0 0 12px rgba(52,211,153,0.2);
}

/* --- Enhanced Cards --- */
.card {
  background: linear-gradient(145deg, rgba(22,22,30,0.75) 0%, rgba(18,18,26,0.65) 100%);
  border: 1px solid rgba(255,255,255,0.05);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: all 0.3s cubic-bezier(0.4,0,0.2,1);
}

.card:hover {
  border-color: rgba(139,92,246,0.15);
  box-shadow: 0 8px 32px rgba(0,0,0,0.3), 0 0 0 1px rgba(139,92,246,0.05);
  transform: translateY(-1px);
}

/* --- Stat Cards Glow --- */
.stat-card {
  background: linear-gradient(145deg, rgba(22,22,30,0.8) 0%, rgba(16,16,24,0.6) 100%);
  border: 1px solid rgba(255,255,255,0.05);
  backdrop-filter: blur(12px);
  transition: all 0.3s cubic-bezier(0.4,0,0.2,1);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(139,92,246,0.5), rgba(96,165,250,0.5), transparent);
  opacity: 0;
  transition: opacity 0.3s;
}

.stat-card:hover::before {
  opacity: 1;
}

.stat-card:hover {
  border-color: rgba(139,92,246,0.12);
  box-shadow: 0 12px 40px rgba(0,0,0,0.3), 0 0 30px rgba(139,92,246,0.05);
  transform: translateY(-3px);
}

.stat-card .stat-number {
  background: linear-gradient(135deg, #e0d4ff 0%, #8b5cf6 30%, #60a5fa 60%, #22d3ee 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  font-feature-settings: 'tnum';
}

/* --- Stats grid staggered entrance --- */
.stats-grid .stat-card {
  animation: cardEnter 0.5s ease backwards;
}
.stats-grid .stat-card:nth-child(1) { animation-delay: 0.05s; }
.stats-grid .stat-card:nth-child(2) { animation-delay: 0.1s; }
.stats-grid .stat-card:nth-child(3) { animation-delay: 0.15s; }
.stats-grid .stat-card:nth-child(4) { animation-delay: 0.2s; }

@keyframes cardEnter {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- Enhanced Buttons --- */
.btn-primary {
  background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 50%, #6d28d9 100%);
  box-shadow: 0 2px 12px rgba(139,92,246,0.25), inset 0 1px 0 rgba(255,255,255,0.1);
  transition: all 0.25s cubic-bezier(0.4,0,0.2,1);
  position: relative;
  overflow: hidden;
}

.btn-primary::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 0%, rgba(255,255,255,0.1) 50%, transparent 100%);
  opacity: 0;
  transition: opacity 0.3s;
}

.btn-primary:hover::before {
  opacity: 1;
}

.btn-primary:hover {
  box-shadow: 0 4px 20px rgba(139,92,246,0.35), inset 0 1px 0 rgba(255,255,255,0.15);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 1px 6px rgba(139,92,246,0.2);
}

/* --- Enhanced Tags --- */
.tag {
  transition: all 0.2s;
  backdrop-filter: blur(4px);
}
.tag:hover {
  transform: scale(1.05);
}

/* --- Enhanced Login Page --- */
.auth-container {
  background:
    radial-gradient(ellipse 50% 40% at 30% 30%, rgba(139,92,246,0.08) 0%, transparent 70%),
    radial-gradient(ellipse 50% 40% at 70% 70%, rgba(96,165,250,0.06) 0%, transparent 70%),
    var(--bg);
}

.auth-card {
  background: linear-gradient(145deg, rgba(22,22,30,0.85) 0%, rgba(16,16,24,0.75) 100%);
  border: 1px solid rgba(255,255,255,0.06);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  box-shadow: 0 20px 60px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.03);
}

.auth-card::before {
  content: '';
  position: absolute;
  top: -1px;
  left: 20%;
  right: 20%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(139,92,246,0.4), transparent);
}

/* --- Enhanced Detail Panel --- */
.detail-panel {
  background: linear-gradient(180deg, #0e0e14 0%, #0a0a10 100%);
  border-left: 1px solid rgba(139,92,246,0.1);
  box-shadow: -8px 0 40px rgba(0,0,0,0.5);
}

/* --- Enhanced Note Items --- */
.note-item {
  transition: all 0.25s cubic-bezier(0.4,0,0.2,1);
  border-radius: var(--radius);
}
.note-item:hover {
  background: rgba(139,92,246,0.04);
  transform: translateX(4px);
}

/* --- Deepen Dialog Enhancement --- */
.deepen-panel {
  border: 1px solid rgba(139,92,246,0.15) !important;
  background: linear-gradient(145deg, rgba(22,22,30,0.9) 0%, rgba(16,16,24,0.85) 100%) !important;
  box-shadow: 0 16px 48px rgba(0,0,0,0.4), 0 0 40px rgba(139,92,246,0.06) !important;
}

/* --- Chat Bubbles --- */
.chat-bubble.user {
  background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 50%, #6d28d9 100%);
  box-shadow: 0 4px 16px rgba(139,92,246,0.25);
}

.chat-bubble.ai {
  background: linear-gradient(145deg, rgba(22,22,30,0.85) 0%, rgba(18,18,26,0.75) 100%);
  border: 1px solid rgba(255,255,255,0.06);
}

/* --- Topic Bars Enhanced --- */
.bar-fill.ai { background: linear-gradient(90deg, #7c3aed, #8b5cf6, #a78bfa); }
.bar-fill.product { background: linear-gradient(90deg, #059669, #10b981, #34d399); }
.bar-fill.investment { background: linear-gradient(90deg, #d97706, #f59e0b, #fbbf24); }
.bar-fill.growth { background: linear-gradient(90deg, #2563eb, #3b82f6, #60a5fa); }

.topic-bar {
  transition: all 0.2s;
}
.topic-bar:hover {
  transform: translateX(4px);
}

.topic-bar:hover .bar-fill {
  filter: brightness(1.15);
}

/* --- Toast Enhancement --- */
.toast {
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.1);
}

/* --- Page Transitions --- */
.page-content {
  animation: pageIn 0.35s ease;
}

@keyframes pageIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- Input Focus Enhancement --- */
input:focus, textarea:focus, select:focus {
  border-color: rgba(139,92,246,0.4) !important;
  box-shadow: 0 0 0 3px rgba(139,92,246,0.1), 0 0 20px rgba(139,92,246,0.05) !important;
}

/* --- Page Header Gradient Line --- */
.page-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 32px;
  right: 32px;
  height: 1px;
  background: linear-gradient(90deg, rgba(139,92,246,0.2), rgba(96,165,250,0.1), transparent);
}

/* --- User Bar Enhancement --- */
.user-bar {
  transition: all 0.2s;
}
.user-bar:hover {
  background: rgba(139,92,246,0.04);
}

.user-avatar {
  background: linear-gradient(135deg, #7c3aed, #6d28d9) !important;
  box-shadow: 0 2px 8px rgba(139,92,246,0.3);
}

/* --- Scrollbar Refinement --- */
::-webkit-scrollbar-thumb {
  background: rgba(139,92,246,0.15);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(139,92,246,0.25);
}

/* --- Dialog Enhancement --- */
.dialog-overlay {
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(8px);
}

.dialog {
  background: linear-gradient(145deg, rgba(22,22,30,0.95) 0%, rgba(16,16,24,0.9) 100%) !important;
  border: 1px solid rgba(139,92,246,0.12) !important;
  box-shadow: 0 24px 64px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.03) !important;
}

/* --- Filter Bar Active States --- */
.filter-bar .active {
  background: linear-gradient(135deg, rgba(139,92,246,0.15), rgba(96,165,250,0.1)) !important;
  border-color: rgba(139,92,246,0.3) !important;
  box-shadow: 0 0 16px rgba(139,92,246,0.08);
}

/* --- Admin Table --- */
.admin-table th {
  background: rgba(139,92,246,0.06) !important;
}
.admin-table tr:hover td {
  background: rgba(139,92,246,0.03);
}

/* --- Card Title Icon Glow --- */
.card-title {
  text-shadow: 0 0 20px rgba(196,181,253,0.15);
}

/* --- Smooth transitions for all interactive elements --- */
a, button, .nav-item, .card, .stat-card, .note-item, .tag, .btn {
  transition: all 0.25s cubic-bezier(0.4,0,0.2,1);
}



/* ============================== */
/* Mobile Enhancement Layer v1.0  */
/* ============================== */

/* Hamburger menu button - hidden on desktop */
.mobile-menu-btn {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 301;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: var(--transition);
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}
.mobile-menu-btn:active { transform: scale(0.92); }

/* Mobile overlay behind sidebar */
.mobile-sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 299;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.mobile-sidebar-overlay.show {
  opacity: 1;
}

/* ---- Tablet: 768-900px ---- */
@media (max-width: 900px) {
  .mobile-menu-btn { display: flex; }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 260px !important;
    min-width: 260px !important;
    z-index: 300;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: none;
  }
  .sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 4px 0 32px rgba(0,0,0,0.5);
  }
  /* Restore hidden items in mobile drawer */
  .sidebar.mobile-open .sidebar-brand h1,
  .sidebar.mobile-open .sidebar-brand .subtitle,
  .sidebar.mobile-open .nav-section-title,
  .sidebar.mobile-open .nav-item span:not(.icon),
  .sidebar.mobile-open .nav-item .badge,
  .sidebar.mobile-open .sidebar-footer { display: flex; }
  .sidebar.mobile-open .nav-item { justify-content: flex-start; padding: 11px 16px; }
  .sidebar.mobile-open .sidebar-status span:not(.status-dot) { display: inline; }
  .sidebar.mobile-open .sidebar-status { justify-content: flex-start; }

  .main {
    width: 100% !important;
    margin-left: 0 !important;
  }

  .page-header {
    padding: 56px 16px 14px !important;
  }
  .page-header h2 { font-size: 20px; }

  .page-content { padding: 14px 16px !important; }

  .stats-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 10px !important; }
  .grid-2, .grid-3 { grid-template-columns: 1fr !important; }

  /* Chat */
  .chat-container { height: calc(100vh - 120px) !important; }
  .chat-bubble { max-width: 90% !important; }

  /* Detail panel full width on tablet */
  .detail-panel { width: 85vw !important; max-width: 85vw !important; }

  /* Knowledge controls */
  .knowledge-controls { gap: 8px; }
  .knowledge-controls select { font-size: 12px; padding: 6px 10px; }

  /* Search */
  .search-input-wrap { flex-direction: column; }
  .search-input-wrap input { width: 100%; }

  /* Toast */
  .toast { right: 12px; left: 12px; max-width: none; }

  /* Admin table scroll */
  .admin-table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Auth box */
  .auth-box { padding: 32px 24px; width: 95%; }
}

/* ---- Phone: < 480px ---- */
@media (max-width: 480px) {
  .page-header {
    padding: 52px 12px 12px !important;
  }
  .page-header h2 { font-size: 18px; }

  .page-content { padding: 10px 12px !important; }

  .stats-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
  }
  .stat-card {
    padding: 12px !important;
  }
  .stat-number { font-size: 22px !important; }
  .stat-label { font-size: 11px !important; }
  .stat-icon { font-size: 18px !important; }

  /* Chat full screen */
  .chat-container { height: calc(100vh - 100px) !important; }
  .chat-bubble { max-width: 92% !important; font-size: 13px !important; padding: 10px 12px !important; }
  .chat-input-area { gap: 6px; }
  .chat-input-area input { font-size: 14px; padding: 10px 12px; }

  /* Detail panel full screen on phone */
  .detail-panel {
    width: 100vw !important;
    max-width: 100vw !important;
    border-left: none !important;
    border-radius: 0 !important;
    padding: 16px !important;
  }
  .detail-panel .detail-title { font-size: 17px; }

  /* Note items */
  .note-item { padding: 10px 12px; }
  .note-item .note-title { font-size: 14px; }
  .note-item .note-meta { font-size: 11px; }

  /* Topic bars */
  .topic-bar .bar-label { width: 48px; font-size: 12px; }
  .topic-bar .bar-count { width: 28px; font-size: 12px; }

  /* Buttons larger touch targets */
  .btn { min-height: 40px; padding: 8px 16px; font-size: 13px; }
  .btn-sm { min-height: 36px; }

  /* Filter bar scrollable */
  .filter-bar { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
  .filter-bar::-webkit-scrollbar { display: none; }

  /* Input larger on mobile */
  input, textarea, select {
    font-size: 16px !important; /* prevents iOS zoom on focus */
  }

  /* Auth */
  .auth-box { padding: 24px 16px; border-radius: 16px; }
  .auth-box h2 { font-size: 22px; }

  /* Collect mode */
  .collect-mode-btn { font-size: 12px; padding: 6px 10px; }

  /* Settings */
  .settings-grid { grid-template-columns: 1fr !important; }

  /* Weekly stats */
  #weeklyStatsGrid { grid-template-columns: 1fr 1fr 1fr !important; gap: 6px !important; }

  /* Deepen messages */
  .deepen-msg { max-width: 92% !important; font-size: 13px; }

  /* Review cards */
  .review-item { padding: 12px; }

  /* User bar compact */
  .user-bar { padding: 8px 12px; }
  .user-menu { left: 8px; right: 8px; }
}

/* Touch feedback for all interactive elements */
@media (hover: none) and (pointer: coarse) {
  .nav-item:active,
  .stat-card:active,
  .note-item:active,
  .card:active,
  .btn:active { opacity: 0.7; transition: opacity 0.1s; }

  /* Disable hover effects on touch */
  .stat-card:hover { transform: none; box-shadow: var(--shadow); }
  .card:hover { box-shadow: var(--shadow); }
  .nav-item:hover { background: transparent; }

  /* Larger scrollbar for touch */
  ::-webkit-scrollbar { width: 3px; }
}

/* Safe area for notched devices */
@supports (padding-top: env(safe-area-inset-top)) {
  .mobile-menu-btn { top: calc(12px + env(safe-area-inset-top)); }
  .page-header { padding-top: calc(56px + env(safe-area-inset-top)) !important; }
  .sidebar { padding-top: env(safe-area-inset-top); }
  .chat-input-area { padding-bottom: env(safe-area-inset-bottom); }
}

