/* ========================================
   CSS Variables / Theme - NEON SYNTHWAVE
   ======================================== */
:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12001a;
  --bg-tertiary: #0d0021;
  --bg-card: rgba(18, 0, 26, 0.8);
  --bg-hover: rgba(0, 255, 240, 0.08);
  --accent: #00fff0;
  --accent-light: #00fff0;
  --accent-dim: rgba(0, 255, 240, 0.15);
  --text-primary: #e0e0ff;
  --text-secondary: #8888aa;
  --text-muted: #555577;
  --border-color: rgba(0, 255, 240, 0.2);
  --user-bubble: rgba(0, 255, 240, 0.08);
  --user-bubble-border: rgba(0, 255, 240, 0.4);
  --assistant-bubble: rgba(255, 0, 255, 0.06);
  --assistant-bubble-border: rgba(255, 0, 255, 0.3);
  --thinking-bg: rgba(100, 0, 200, 0.1);
  --tool-bg: rgba(0, 40, 0, 0.3);
  --tool-border: rgba(57, 255, 20, 0.3);
  --success: #39ff14;
  --warning: #ff6600;
  --error: #ff0040;
  --neon-pink: #ff00ff;
  --neon-cyan: #00fff0;
  --neon-yellow: #ffff00;
  --neon-green: #39ff14;
  --sidebar-width: 280px;
  --header-height: 56px;
  --radius: 8px;
  --radius-lg: 12px;
  --transition: 200ms ease;
}

/* ========================================
   Reset & Base
   ======================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  overflow: hidden;
  height: 100vh;
  position: relative;
}

body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background:
    linear-gradient(180deg, transparent 60%, rgba(10, 0, 20, 0.8) 100%),
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 2px,
      rgba(0, 255, 240, 0.015) 2px,
      rgba(0, 255, 240, 0.015) 4px
    );
  pointer-events: none;
  z-index: 9999;
}

a {
  color: var(--accent-light);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
  text-shadow: 0 0 8px rgba(0, 255, 240, 0.5);
}

/* ========================================
   Layout
   ======================================== */
#app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ========================================
   Sidebar
   ======================================== */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform var(--transition);
  z-index: 100;
  box-shadow: 1px 0 15px rgba(0, 255, 240, 0.05);
}

.sidebar-header {
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border-color);
  background: linear-gradient(180deg, var(--bg-tertiary), var(--bg-secondary));
}

.logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent-light);
  letter-spacing: -0.02em;
  text-shadow: 0 0 10px rgba(0, 255, 240, 0.6), 0 0 20px rgba(0, 255, 240, 0.3);
}

.sidebar-nav {
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--transition);
  text-decoration: none;
}

.nav-link:hover {
  background: var(--bg-hover);
  color: var(--neon-cyan);
  text-decoration: none;
  text-shadow: 0 0 8px rgba(0, 255, 240, 0.4);
}

.nav-link.active {
  background: var(--accent-dim);
  color: var(--accent-light);
  text-shadow: 0 0 10px rgba(0, 255, 240, 0.6);
  box-shadow: inset 0 0 10px rgba(0, 255, 240, 0.1), 0 0 5px rgba(0, 255, 240, 0.15);
}

.sidebar-sessions {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  border-top: 1px solid var(--border-color);
}

.sidebar-section-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 8px 12px 4px;
  font-weight: 600;
}

.sidebar-session-item {
  display: block;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 0.82rem;
  transition: all var(--transition);
  text-decoration: none;
  cursor: pointer;
  line-height: 1.4;
}

.sidebar-session-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  text-decoration: none;
}

.sidebar-session-item.active {
  background: var(--accent-dim);
  color: var(--accent-light);
  box-shadow: inset 0 0 8px rgba(0, 255, 240, 0.1);
  border-left: 2px solid var(--neon-cyan);
}

.sidebar-session-title {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}

.sidebar-session-meta {
  display: flex;
  gap: 8px;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ========================================
   Main Content
   ======================================== */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.view-container {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* ========================================
   Mobile Header
   ======================================== */
.mobile-header {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
}

.menu-toggle {
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
}

.mobile-title {
  font-weight: 600;
  font-size: 1rem;
  color: var(--accent-light);
  text-shadow: 0 0 10px rgba(0, 255, 240, 0.5);
}

/* ========================================
   Dashboard
   ======================================== */
.dashboard-header {
  margin-bottom: 24px;
}

.dashboard-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  text-shadow: 0 0 15px rgba(0, 255, 240, 0.4), 0 0 30px rgba(0, 255, 240, 0.15);
}

.dashboard-header p {
  color: var(--text-secondary);
  margin-top: 4px;
  font-size: 0.9rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: all var(--transition);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 0 10px rgba(0, 255, 240, 0.05);
}

.stat-card:hover {
  border-color: var(--neon-cyan);
  border-left: 3px solid var(--neon-cyan);
  box-shadow: 0 0 15px rgba(0, 255, 240, 0.15), 0 0 30px rgba(0, 255, 240, 0.05);
}

.stat-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--neon-cyan);
  margin-top: 4px;
  line-height: 1.2;
  text-shadow: 0 0 15px rgba(0, 255, 240, 0.5), 0 0 30px rgba(0, 255, 240, 0.2);
}

.stat-detail {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

.recent-section h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-primary);
  text-shadow: 0 0 10px rgba(0, 255, 240, 0.3);
}

/* ========================================
   Session List
   ======================================== */
.sessions-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.sessions-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  text-shadow: 0 0 15px rgba(0, 255, 240, 0.4), 0 0 30px rgba(0, 255, 240, 0.15);
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 8px 14px;
  width: 300px;
  max-width: 100%;
  transition: all var(--transition);
}

.search-bar:focus-within {
  border-color: var(--neon-cyan);
  box-shadow: 0 0 10px rgba(0, 255, 240, 0.2), 0 0 20px rgba(0, 255, 240, 0.08);
}

.search-bar svg {
  color: var(--text-muted);
  flex-shrink: 0;
}

.search-bar input {
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 0.9rem;
  width: 100%;
  outline: none;
}

.search-bar input::placeholder {
  color: var(--text-muted);
}

.session-table {
  width: 100%;
  border-collapse: collapse;
}

.session-table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

.session-table th:hover {
  color: var(--neon-cyan);
  text-shadow: 0 0 5px rgba(0, 255, 240, 0.3);
}

.session-table th .sort-icon {
  margin-left: 4px;
  opacity: 0.4;
}

.session-table th.sorted .sort-icon {
  opacity: 1;
  color: var(--accent-light);
}

.session-table td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(0, 255, 240, 0.08);
  font-size: 0.88rem;
}

.session-table tr {
  transition: background var(--transition);
  cursor: pointer;
}

.session-table tbody tr:hover {
  background: var(--bg-hover);
  box-shadow: inset 0 0 20px rgba(0, 255, 240, 0.03);
}

.session-title-cell {
  color: var(--text-primary);
  font-weight: 500;
  max-width: 400px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-id-cell {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.session-count-cell {
  color: var(--text-secondary);
}

.session-date-cell {
  color: var(--text-secondary);
  white-space: nowrap;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 0.72rem;
  font-weight: 600;
  border: 1px solid transparent;
}

.badge-model {
  background: transparent;
  color: var(--neon-cyan);
  border-color: var(--neon-cyan);
  box-shadow: 0 0 5px rgba(0, 255, 240, 0.2);
}

/* ========================================
   Session Detail / Chat View
   ======================================== */
.session-detail-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
}

.back-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius);
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}

.back-btn:hover {
  background: var(--bg-hover);
  color: var(--neon-cyan);
  border-color: var(--neon-cyan);
  box-shadow: 0 0 8px rgba(0, 255, 240, 0.2);
  text-decoration: none;
}

.session-detail-title {
  font-size: 1.2rem;
  font-weight: 700;
  flex: 1;
  min-width: 0;
  text-shadow: 0 0 10px rgba(0, 255, 240, 0.3);
}

.session-detail-meta {
  display: flex;
  gap: 16px;
  font-size: 0.8rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.session-detail-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 900px;
  margin: 0 auto;
  padding-bottom: 40px;
}

/* ========================================
   Message Bubbles
   ======================================== */
.message {
  display: flex;
  flex-direction: column;
  max-width: 85%;
  animation: fadeInUp 0.2s ease;
}

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

.message-user {
  align-self: flex-end;
}

.message-assistant {
  align-self: flex-start;
}

.message-system {
  align-self: center;
  max-width: 70%;
}

.message-bubble {
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  line-height: 1.65;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.message-user .message-bubble {
  background: var(--user-bubble);
  border: 1px solid var(--user-bubble-border);
  border-bottom-right-radius: 4px;
  box-shadow: 0 0 10px rgba(0, 255, 240, 0.1), inset 0 0 15px rgba(0, 255, 240, 0.03);
}

.message-assistant .message-bubble {
  background: var(--assistant-bubble);
  border: 1px solid var(--assistant-bubble-border);
  border-bottom-left-radius: 4px;
  box-shadow: 0 0 10px rgba(255, 0, 255, 0.1), inset 0 0 15px rgba(255, 0, 255, 0.03);
}

.message-system .message-bubble {
  background: rgba(255, 255, 0, 0.05);
  border: 1px solid rgba(255, 255, 0, 0.2);
  font-size: 0.82rem;
  color: var(--neon-yellow);
  text-align: center;
  border-radius: 9999px;
  padding: 6px 16px;
  box-shadow: 0 0 8px rgba(255, 255, 0, 0.08);
}

.message-role {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  margin-bottom: 4px;
}

.message-user .message-role {
  color: var(--neon-cyan);
  text-align: right;
  text-shadow: 0 0 6px rgba(0, 255, 240, 0.4);
}

.message-assistant .message-role {
  color: var(--neon-pink);
  text-shadow: 0 0 6px rgba(255, 0, 255, 0.4);
}

.message-timestamp {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.message-user .message-timestamp {
  text-align: right;
}

/* ========================================
   Markdown Content
   ======================================== */
.message-content {
  font-size: 0.92rem;
}

.message-content p {
  margin-bottom: 8px;
}

.message-content p:last-child {
  margin-bottom: 0;
}

.message-content h1, .message-content h2, .message-content h3,
.message-content h4, .message-content h5, .message-content h6 {
  margin-top: 16px;
  margin-bottom: 8px;
  font-weight: 600;
  line-height: 1.3;
  text-shadow: 0 0 8px rgba(0, 255, 240, 0.3);
}

.message-content h1 { font-size: 1.3rem; }
.message-content h2 { font-size: 1.15rem; }
.message-content h3 { font-size: 1.05rem; }

.message-content ul, .message-content ol {
  margin: 8px 0;
  padding-left: 24px;
}

.message-content li {
  margin-bottom: 4px;
}

.message-content blockquote {
  border-left: 3px solid var(--neon-pink);
  padding-left: 12px;
  margin: 8px 0;
  color: var(--text-secondary);
  box-shadow: -3px 0 10px rgba(255, 0, 255, 0.15);
}

.message-content code {
  background: rgba(0, 255, 240, 0.08);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 0.85em;
  color: var(--neon-green);
  border: 1px solid rgba(57, 255, 20, 0.15);
}

.message-content pre {
  margin: 10px 0;
  border-radius: var(--radius);
  overflow-x: auto;
  background: rgba(0, 5, 0, 0.6);
  border: 1px solid rgba(57, 255, 20, 0.2);
  position: relative;
}

.message-content pre::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(57, 255, 20, 0.02) 2px,
    rgba(57, 255, 20, 0.02) 4px
  );
  pointer-events: none;
  border-radius: var(--radius);
}

.message-content pre code {
  background: none;
  padding: 12px;
  border-radius: 0;
  font-size: 0.85rem;
  line-height: 1.5;
  display: block;
  color: var(--neon-green);
  border: none;
}

.message-content table {
  border-collapse: collapse;
  margin: 8px 0;
  width: 100%;
  font-size: 0.88rem;
}

.message-content th, .message-content td {
  border: 1px solid rgba(0, 255, 240, 0.15);
  padding: 6px 10px;
  text-align: left;
}

.message-content th {
  background: rgba(0, 255, 240, 0.08);
  font-weight: 600;
  color: var(--neon-cyan);
}

.message-content img {
  max-width: 100%;
  border-radius: var(--radius);
}

.message-content hr {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 16px 0;
  box-shadow: 0 0 5px rgba(0, 255, 240, 0.15);
}

/* ========================================
   Tool Use Blocks
   ======================================== */
.tool-block {
  margin: 8px 0;
  border: 1px solid var(--tool-border);
  border-radius: var(--radius);
  background: var(--tool-bg);
  overflow: hidden;
  box-shadow: 0 0 8px rgba(57, 255, 20, 0.05);
}

.tool-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  user-select: none;
  transition: background var(--transition);
  font-size: 0.82rem;
}

.tool-header:hover {
  background: rgba(57, 255, 20, 0.05);
}

.tool-chevron {
  transition: transform var(--transition);
  color: var(--neon-green);
  flex-shrink: 0;
}

.tool-block.expanded .tool-chevron {
  transform: rotate(90deg);
}

.tool-name {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-weight: 600;
  color: var(--neon-green);
  font-size: 0.82rem;
  text-shadow: 0 0 6px rgba(57, 255, 20, 0.4);
}

.tool-badge {
  font-size: 0.68rem;
  padding: 1px 6px;
  border-radius: 4px;
  background: transparent;
  color: var(--neon-green);
  font-weight: 500;
  border: 1px solid rgba(57, 255, 20, 0.3);
}

.tool-body {
  display: none;
  padding: 0 12px 12px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.78rem;
  line-height: 1.5;
}

.tool-block.expanded .tool-body {
  display: block;
}

.tool-section-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--neon-green);
  margin-top: 8px;
  margin-bottom: 4px;
  font-weight: 600;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  opacity: 0.7;
}

.tool-content {
  background: rgba(0, 5, 0, 0.5);
  border-radius: 4px;
  padding: 8px 10px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--neon-green);
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid rgba(57, 255, 20, 0.1);
}

/* ========================================
   Thinking Blocks
   ======================================== */
.thinking-block {
  margin: 8px 0;
  border: 1px solid rgba(255, 0, 255, 0.2);
  border-radius: var(--radius);
  background: var(--thinking-bg);
  overflow: hidden;
  box-shadow: 0 0 8px rgba(100, 0, 200, 0.1);
}

.thinking-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  user-select: none;
  font-size: 0.82rem;
  color: var(--neon-pink);
  font-style: italic;
  transition: background var(--transition);
  text-shadow: 0 0 5px rgba(255, 0, 255, 0.3);
}

.thinking-header:hover {
  background: rgba(255, 0, 255, 0.05);
}

.thinking-chevron {
  transition: transform var(--transition);
  color: var(--neon-pink);
  flex-shrink: 0;
}

.thinking-block.expanded .thinking-chevron {
  transform: rotate(90deg);
}

.thinking-body {
  display: none;
  padding: 0 12px 12px;
  font-size: 0.82rem;
  color: rgba(255, 0, 255, 0.6);
  font-style: italic;
  line-height: 1.6;
  max-height: 500px;
  overflow-y: auto;
}

.thinking-block.expanded .thinking-body {
  display: block;
}

/* ========================================
   Tool Result (in user messages)
   ======================================== */
.tool-result-block {
  margin: 4px 0;
  padding: 8px 10px;
  background: rgba(0, 5, 0, 0.4);
  border-radius: 4px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.78rem;
  color: var(--neon-green);
  max-height: 300px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
  border: 1px solid rgba(57, 255, 20, 0.1);
}

/* ========================================
   Loading State
   ======================================== */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(0, 255, 240, 0.15);
  border-top-color: var(--neon-cyan);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 12px;
  box-shadow: 0 0 15px rgba(0, 255, 240, 0.2);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  font-size: 0.9rem;
  color: var(--neon-cyan);
  text-shadow: 0 0 8px rgba(0, 255, 240, 0.3);
}

/* ========================================
   Empty State
   ======================================== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-muted);
  text-align: center;
}

.empty-state svg {
  margin-bottom: 16px;
  opacity: 0.4;
}

.empty-state h3 {
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.empty-state p {
  font-size: 0.88rem;
}

/* ========================================
   Error State
   ======================================== */
.error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  color: var(--error);
  text-align: center;
}

.error-state h3 {
  font-size: 1.1rem;
  margin-bottom: 8px;
  text-shadow: 0 0 10px rgba(255, 0, 64, 0.5);
}

.error-state p {
  font-size: 0.88rem;
  color: var(--text-muted);
}

.retry-btn {
  margin-top: 12px;
  padding: 8px 16px;
  border-radius: var(--radius);
  background: transparent;
  color: var(--neon-cyan);
  border: 1px solid var(--neon-cyan);
  cursor: pointer;
  font-size: 0.85rem;
  transition: all var(--transition);
  box-shadow: 0 0 5px rgba(0, 255, 240, 0.2);
}

.retry-btn:hover {
  background: rgba(0, 255, 240, 0.1);
  box-shadow: 0 0 15px rgba(0, 255, 240, 0.3), 0 0 30px rgba(0, 255, 240, 0.1);
}

/* ========================================
   Scrollbar
   ======================================== */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.3);
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--neon-cyan), var(--neon-pink));
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, var(--neon-cyan), var(--neon-yellow));
  box-shadow: 0 0 5px rgba(0, 255, 240, 0.5);
}

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0, 255, 240, 0.15);
  }

  .mobile-header {
    display: flex;
  }

  .view-container {
    padding: 16px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .sessions-header {
    flex-direction: column;
    align-items: stretch;
  }

  .search-bar {
    width: 100%;
  }

  .session-table {
    display: block;
    overflow-x: auto;
  }

  .message {
    max-width: 95%;
  }

  .session-detail-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .session-detail-meta {
    flex-direction: column;
    gap: 4px;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .chat-messages {
    gap: 12px;
  }

  .message-bubble {
    padding: 10px 12px;
  }
}

/* Sidebar overlay on mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 99;
}

.sidebar-overlay.visible {
  display: block;
}

/* ========================================
   Utility
   ======================================== */
.truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mono {
  font-family: 'SF Mono', 'Fira Code', monospace;
}

.text-muted {
  color: var(--text-muted);
}

.text-secondary {
  color: var(--text-secondary);
}

.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }

/* ========================================
   Subagent Components
   ======================================== */
.subagent-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: 9999px;
  font-size: 0.72rem;
  font-weight: 600;
  background: transparent;
  color: var(--neon-pink);
  white-space: nowrap;
  border: 1px solid rgba(255, 0, 255, 0.4);
  box-shadow: 0 0 5px rgba(255, 0, 255, 0.15);
}

.subagent-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.subagent-icon svg {
  width: 14px;
  height: 14px;
}

.subagent-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.subagent-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px;
  cursor: pointer;
  transition: all var(--transition);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.subagent-card:hover {
  border-color: var(--neon-pink);
  transform: translateY(-2px);
  box-shadow: 0 0 15px rgba(255, 0, 255, 0.2), 0 4px 20px rgba(0, 0, 0, 0.4);
}

.subagent-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.subagent-card-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.subagent-card-body .session-card-title {
  font-weight: 600;
}

.subagent-agent-id {
  display: inline-block;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.72rem;
  font-weight: 600;
  background: transparent;
  color: var(--neon-pink);
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap;
  border: 1px solid rgba(255, 0, 255, 0.3);
}

.subagent-slug {
  color: var(--text-secondary);
  font-style: italic;
  font-size: 0.85rem;
}

.subagent-list-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
}

.subagent-detail-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
}

.subagent-summary-panel {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  margin-bottom: 20px;
  overflow: hidden;
}

.subagent-summary-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  cursor: pointer;
  user-select: none;
  transition: background var(--transition);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
}

.subagent-summary-header:hover {
  background: var(--bg-hover);
}

.subagent-summary-header .tool-chevron {
  transition: transform var(--transition);
}

.subagent-summary-panel.expanded .subagent-summary-header .tool-chevron {
  transform: rotate(90deg);
}

.subagent-summary-list {
  display: none;
  border-top: 1px solid var(--border-color);
}

.subagent-summary-panel.expanded .subagent-summary-list {
  display: block;
}

.subagent-summary-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: background var(--transition);
  font-size: 0.85rem;
  text-decoration: none;
  color: var(--text-secondary);
}

.subagent-summary-item:last-child {
  border-bottom: none;
}

.subagent-summary-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  text-decoration: none;
}

.subagent-summary-name {
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
}

.subagent-summary-title {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-muted);
}

.subagent-summary-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.subagent-header-link {
  color: var(--accent-light);
  font-size: 0.8rem;
  font-weight: 500;
}

.session-subagent-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ========================================
   Tab Bar
   ======================================== */
.tab-bar {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 20px;
}

.tab-item {
  padding: 10px 20px;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.9rem;
  transition: all var(--transition);
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  user-select: none;
}

.tab-item:hover {
  color: var(--neon-cyan);
  background: rgba(0, 255, 240, 0.03);
}

.tab-item.active {
  color: var(--neon-cyan);
  border-bottom-color: var(--neon-cyan);
  font-weight: 600;
  text-shadow: 0 0 8px rgba(0, 255, 240, 0.4);
  box-shadow: 0 2px 8px rgba(0, 255, 240, 0.15);
}

/* ========================================
   Breadcrumb
   ======================================== */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.breadcrumb a {
  color: var(--accent-light);
  text-decoration: none;
}

.breadcrumb a:hover {
  text-decoration: underline;
  text-shadow: 0 0 5px rgba(0, 255, 240, 0.4);
}

.breadcrumb-separator {
  color: var(--text-muted);
  font-weight: 300;
}

/* ========================================
   View Toggle & Session Cards Grid
   ======================================== */
.view-toggle {
  display: inline-flex;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  overflow: hidden;
}

.view-toggle-btn {
  padding: 6px 12px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all var(--transition);
}

.view-toggle-btn:hover {
  color: var(--neon-cyan);
  background: rgba(0, 255, 240, 0.05);
}

.view-toggle-btn.active {
  background: var(--accent-dim);
  color: var(--neon-cyan);
  box-shadow: inset 0 0 10px rgba(0, 255, 240, 0.1);
}

.session-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.session-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px;
  cursor: pointer;
  transition: all var(--transition);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.session-card:hover {
  border-color: var(--neon-cyan);
  box-shadow: 0 0 15px rgba(0, 255, 240, 0.15), 0 0 30px rgba(0, 255, 240, 0.05);
}

.session-card-title {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.session-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ========================================
   Search Enhancements
   ======================================== */
.search-snippet {
  margin-top: 4px;
  padding: 8px;
  background: var(--bg-tertiary);
  border-radius: var(--radius);
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
  border: 1px solid rgba(0, 255, 240, 0.08);
}

.search-highlight {
  background: rgba(255, 255, 0, 0.25);
  color: var(--neon-yellow);
  padding: 0 2px;
  border-radius: 2px;
  text-shadow: 0 0 5px rgba(255, 255, 0, 0.3);
}

/* ========================================
   Quick Actions
   ======================================== */
.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
  margin-bottom: 24px;
}

.action-btn {
  padding: 10px 20px;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-weight: 500;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all var(--transition);
}

.action-btn:hover {
  border-color: var(--neon-cyan);
  color: var(--neon-cyan);
  background: rgba(0, 255, 240, 0.05);
  box-shadow: 0 0 10px rgba(0, 255, 240, 0.15), 0 0 20px rgba(0, 255, 240, 0.05);
  text-shadow: 0 0 5px rgba(0, 255, 240, 0.3);
}

/* ========================================
   Activity Summary
   ======================================== */
.activity-summary {
  padding: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-top: 24px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

/* ========================================
   Sidebar Group Header
   ======================================== */
.sidebar-group-header {
  padding: 12px 12px 4px;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--neon-cyan);
  font-weight: 700;
  margin-top: 8px;
  text-shadow: 0 0 5px rgba(0, 255, 240, 0.3);
  opacity: 0.7;
}

/* ========================================
   Jump to Bottom / Floating Button
   ======================================== */
.jump-to-bottom {
  position: fixed;
  bottom: 32px;
  right: 32px;
  background: transparent;
  color: var(--neon-cyan);
  border: 1px solid var(--neon-cyan);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 0 10px rgba(0, 255, 240, 0.3), 0 0 20px rgba(0, 255, 240, 0.1);
  transition: all var(--transition);
  opacity: 0;
  pointer-events: none;
  z-index: 50;
}

.jump-to-bottom.visible {
  opacity: 1;
  pointer-events: auto;
}

.jump-to-bottom:hover {
  transform: scale(1.1);
  background: rgba(0, 255, 240, 0.1);
  box-shadow: 0 0 15px rgba(0, 255, 240, 0.4), 0 0 30px rgba(0, 255, 240, 0.2);
}

/* ========================================
   Duration Cell
   ======================================== */
.duration-cell {
  color: var(--text-muted);
  font-size: 0.82rem;
  white-space: nowrap;
}

/* ========================================
   Message Count Badge
   ======================================== */
.message-count-badge {
  text-align: center;
  font-size: 0.78rem;
  color: var(--neon-cyan);
  padding: 4px 12px;
  background: transparent;
  border: 1px solid rgba(0, 255, 240, 0.2);
  border-radius: 9999px;
  margin-bottom: 12px;
  display: inline-block;
  box-shadow: 0 0 5px rgba(0, 255, 240, 0.1);
}

/* ========================================
   Teammate Message Styling
   ======================================== */
.teammate-message {
  border-left: 3px solid var(--neon-pink);
  padding-left: 12px;
  margin: 4px 0;
  box-shadow: -3px 0 8px rgba(255, 0, 255, 0.1);
}

.teammate-badge {
  display: inline-block;
  background: transparent;
  color: var(--neon-pink);
  font-size: 0.72rem;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 600;
  border: 1px solid rgba(255, 0, 255, 0.3);
  box-shadow: 0 0 5px rgba(255, 0, 255, 0.15);
}

/* ========================================
   Responsive (New Components)
   ======================================== */
@media (max-width: 768px) {
  .subagent-cards-grid {
    grid-template-columns: 1fr;
  }

  .session-cards-grid {
    grid-template-columns: 1fr;
  }

  .tab-bar {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .tab-bar::-webkit-scrollbar {
    display: none;
  }

  .tab-item {
    white-space: nowrap;
    flex-shrink: 0;
  }

  .quick-actions {
    flex-direction: column;
  }

  .action-btn {
    width: 100%;
    text-align: center;
  }

  .breadcrumb {
    font-size: 0.78rem;
    gap: 6px;
  }

  .subagent-list-header,
  .subagent-detail-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .jump-to-bottom {
    bottom: 20px;
    right: 20px;
  }
}

@media (max-width: 480px) {
  .session-card {
    padding: 12px;
  }

  .subagent-card {
    padding: 12px;
  }

  .view-toggle-btn {
    padding: 5px 8px;
    font-size: 0.75rem;
  }
}

/* ========================================
   Neon Animations
   ======================================== */
@keyframes neon-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

@keyframes neon-flicker {
  0%, 19%, 21%, 23%, 25%, 54%, 56%, 100% { opacity: 1; }
  20%, 24%, 55% { opacity: 0.5; }
}

@keyframes glow-breathe {
  0%, 100% { box-shadow: 0 0 5px var(--neon-cyan), 0 0 10px rgba(0, 255, 240, 0.3); }
  50% { box-shadow: 0 0 10px var(--neon-cyan), 0 0 20px rgba(0, 255, 240, 0.5); }
}

@keyframes border-glow-pulse {
  0%, 100% { border-color: rgba(0, 255, 240, 0.3); }
  50% { border-color: rgba(0, 255, 240, 0.6); }
}

/* Apply subtle pulse to live/active indicators */
.spinner {
  animation: spin 0.8s linear infinite;
  filter: drop-shadow(0 0 5px var(--neon-cyan));
}

/* Subtle glow-breathe on hover for interactive cards */
.stat-card:hover,
.session-card:hover,
.subagent-card:hover {
  animation: glow-breathe 2s ease-in-out infinite;
}

/* Neon glow on focus for all inputs */
input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--neon-cyan);
  box-shadow: 0 0 10px rgba(0, 255, 240, 0.2), 0 0 20px rgba(0, 255, 240, 0.08);
}

/* Subtle selection color */
::selection {
  background: rgba(0, 255, 240, 0.25);
  color: #ffffff;
}

::-moz-selection {
  background: rgba(0, 255, 240, 0.25);
  color: #ffffff;
}
