/**
 * HuntLaw Apprentice - Dark Theme
 * Inspired by Claude homepage aesthetic
 * Colors: #A51C30 (crimson), #525a62 (slate), white text
 */

:root {
  /* Background hierarchy (darkest to lightest) */
  --bg-deep: #0f0f0f;
  --bg-primary: #1a1a1a;
  --bg-elevated: #242424;
  --bg-surface: #2e2e2e;
  --bg-hover: #383838;

  /* Brand colors */
  --crimson: #A51C30;
  --crimson-hover: #8a1728;
  --crimson-light: #c42339;
  --crimson-subtle: rgba(165, 28, 48, 0.15);
  --crimson-glow: rgba(165, 28, 48, 0.3);

  --slate: #525a62;
  --slate-light: #6b747d;
  --slate-dark: #3d444b;

  /* Text hierarchy */
  --text-primary: #ffffff;
  --text-secondary: #a8a8a8;
  --text-muted: #666666;
  --text-disabled: #444444;

  /* Borders */
  --border-subtle: #2a2a2a;
  --border-default: #3a3a3a;
  --border-strong: #4a4a4a;

  /* Semantic colors */
  --success: #22c55e;
  --success-subtle: rgba(34, 197, 94, 0.15);
  --warning: #f59e0b;
  --warning-subtle: rgba(245, 158, 11, 0.15);
  --danger: #ef4444;
  --danger-subtle: rgba(239, 68, 68, 0.15);
  --info: #3b82f6;
  --info-subtle: rgba(59, 130, 246, 0.15);

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.7);
  --shadow-glow: 0 0 20px var(--crimson-glow);

  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  --font-mono: 'SF Mono', Monaco, 'Cascadia Code', 'Consolas', monospace;
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.25rem;
  --font-size-2xl: 1.5rem;

  /* Border radius */
  --radius-sm: 4px;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 100ms ease;
  --transition: 150ms ease;
  --transition-slow: 300ms ease;

  /* Layout */
  --header-height: 56px;
  --chat-width: 35%;
  --editor-width: 65%;
  --mindmap-width: 0%;
}

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

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

body {
  font-family: var(--font-sans);
  background: var(--bg-deep);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--slate);
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-primary);
}

h1 { font-size: var(--font-size-2xl); }
h2 { font-size: var(--font-size-xl); }
h3 { font-size: var(--font-size-lg); }

p {
  margin-bottom: var(--space-md);
  color: var(--text-secondary);
}

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

a:hover {
  color: var(--crimson);
}

/* =====================================================
   HEADER
   ===================================================== */
.apprentice-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-lg);
  z-index: 100;
}

.apprentice-header-left {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.apprentice-logo {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-weight: 600;
  color: var(--text-primary);
}

.apprentice-logo svg {
  width: 24px;
  height: 24px;
  fill: var(--crimson);
}

.apprentice-title {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  padding-left: var(--space-md);
  border-left: 1px solid var(--border-default);
}

.apprentice-header-right {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

/* Matter Display & Dropdown */
.apprentice-matter-display {
  position: relative;
}

.matter-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 320px;
  max-width: 400px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  z-index: 1000;
  max-height: 400px;
  display: flex;
  flex-direction: column;
}

.matter-dropdown.hidden {
  display: none;
}

.matter-dropdown-search {
  padding: var(--space-sm);
  border-bottom: 1px solid var(--border-subtle);
}

.matter-dropdown-search input {
  width: 100%;
  padding: var(--space-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: var(--font-size-sm);
}

.matter-dropdown-list {
  overflow-y: auto;
  max-height: 340px;
  padding: var(--space-xs);
}

.matter-dropdown-item {
  padding: var(--space-sm) var(--space-md);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
  margin-bottom: 2px;
}

.matter-dropdown-item:hover {
  background: var(--bg-hover);
}

.matter-dropdown-item-name {
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 2px;
  font-size: var(--font-size-sm);
}

.matter-dropdown-item-client {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
}

.matter-dropdown-item.intake-option {
  background: rgba(165, 28, 48, 0.05);
  border: 1px solid rgba(165, 28, 48, 0.2);
}

.matter-dropdown-item.intake-option:hover {
  background: rgba(165, 28, 48, 0.1);
  border-color: rgba(165, 28, 48, 0.3);
}

.matter-dropdown-item.intake-option .matter-dropdown-item-name {
  color: var(--crimson);
  font-weight: 600;
}

.matter-dropdown-divider {
  height: 1px;
  background: var(--border-default);
  margin: var(--space-sm) 0;
}

.matter-dropdown-empty {
  padding: var(--space-lg);
  text-align: center;
  color: var(--text-tertiary);
  font-size: var(--font-size-sm);
}

.apprentice-header-btn {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  background: transparent;
  border: 1px solid var(--border-default);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
  cursor: pointer;
  transition: all var(--transition);
}

.apprentice-header-btn:hover {
  background: var(--bg-surface);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.apprentice-header-btn.primary {
  background: var(--crimson);
  border-color: var(--crimson);
  color: white;
}

.apprentice-header-btn.primary:hover {
  background: var(--crimson-hover);
  border-color: var(--crimson-hover);
}

.apprentice-user {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding-left: var(--space-md);
  border-left: 1px solid var(--border-default);
  margin-left: var(--space-sm);
}

.apprentice-user-name {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: color 0.2s;
}

.apprentice-user-name:hover {
  color: var(--text-primary);
  text-decoration: underline;
}

.apprentice-user-role {
  font-size: var(--font-size-xs);
  background: var(--slate-dark);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  color: var(--text-muted);
  text-transform: uppercase;
}

/* Role-specific badge styles for RBAC system */
.user-badge {
  font-size: var(--font-size-xs);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  font-weight: 600;
}

.user-badge.admin {
  background-color: #FFD700; /* Gold */
  color: #1a1a1a; /* Dark text for contrast */
}

.user-badge.attorney {
  background-color: #c41e3a; /* Crimson red */
  color: white;
}

.user-badge.law_clerk {
  background-color: #c41e3a; /* Crimson red */
  color: white;
}

.user-badge.client {
  background-color: #c41e3a; /* Crimson red */
  color: white;
}

/* System badge for "APPRENTICE" */
.system-badge {
  font-size: var(--font-size-xs);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background-color: rgba(255, 255, 255, 0.15); /* Lighter white/translucent */
  color: white;
  text-transform: uppercase;
  font-weight: 500;
}

/* =====================================================
   MAIN LAYOUT - Split Panels
   ===================================================== */
.apprentice-main {
  display: flex;
  height: calc(100vh - var(--header-height));
  margin-top: var(--header-height);
}

.apprentice-chat-panel {
  display: none; /* Hidden in single-panel design */
}

.apprentice-editor-panel {
  width: 100%; /* Full width - no split-screen */
  display: flex;
  flex-direction: column;
  background: var(--bg-deep);
}

/* Initial state: hide all UI except book button */
.apprentice-editor-panel.apprentice-editor-initial .apprentice-editor-tabs,
.apprentice-editor-panel.apprentice-editor-initial .secondary-tabs-row,
.apprentice-editor-panel.apprentice-editor-initial .apprentice-editor-header,
.apprentice-editor-panel.apprentice-editor-initial .apprentice-editor-footer {
  display: none;
}

.apprentice-editor-panel.apprentice-editor-initial .case-file-empty-state {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* =====================================================
   EDITOR MAIN TABS (Editor vs History)
   ===================================================== */
.editor-main-tabs {
  display: flex;
  gap: var(--space-sm);
  padding: var(--space-md);
  border-bottom: 1px solid var(--border-default);
  background: var(--bg-surface);
}

.editor-main-tab {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  background: transparent;
  border: 1px solid var(--border-default);
  border-radius: var(--radius);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  font-size: var(--font-size-sm);
}

.editor-main-tab:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.editor-main-tab.active {
  background: var(--crimson);
  color: white;
  border-color: var(--crimson);
}

.editor-main-tab svg {
  width: 14px;
  height: 14px;
}

/* History Panel */
.history-panel-content {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.history-panel-content.hidden {
  display: none;
}

.history-panel-header {
  padding: var(--space-lg);
  border-bottom: 1px solid var(--border-default);
}

.history-panel-header h3 {
  margin: 0 0 var(--space-md) 0;
  font-size: var(--font-size-lg);
  color: var(--text-primary);
}

.history-search {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: var(--font-size-sm);
}

.history-list {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-md);
}

/* Session Groups */
.session-group {
  margin-bottom: var(--space-xl);
}

.session-group-header {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.session-group-matter {
  font-size: var(--font-size-md);
  font-weight: 600;
  color: var(--crimson);
  margin-bottom: var(--space-sm);
  padding-bottom: var(--space-xs);
  border-bottom: 2px solid var(--border-default);
}

.session-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius);
  margin-bottom: var(--space-sm);
  cursor: pointer;
  transition: all var(--transition);
}

.session-item:hover {
  background: var(--bg-hover);
  border-color: var(--crimson);
  transform: translateX(4px);
}

.session-item-main {
  flex: 1;
  min-width: 0;
}

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

.session-item-meta {
  display: flex;
  gap: var(--space-md);
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
}

.session-item-icon {
  color: var(--text-tertiary);
  transition: color var(--transition);
}

.session-item:hover .session-item-icon {
  color: var(--crimson);
}

/* Option Categories (for matter page) */
.option-category {
  margin-bottom: var(--space-xl);
}

.option-category-title {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--crimson);
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-xs);
  border-bottom: 2px solid var(--border-strong);
}

.option-category .adventure-options {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

/* =====================================================
   DOCUMENT TABS
   ===================================================== */
.apprentice-editor-tabs {
  display: flex;
  align-items: center;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-subtle);
  padding: var(--space-xs) var(--space-sm);
  gap: var(--space-xs);
  min-height: 40px;
}

.tab-list {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  flex: 1;
  scrollbar-width: none;
}

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

.document-tab {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: var(--font-size-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  max-width: 180px;
}

.document-tab:hover {
  background: var(--bg-hover);
  color: var(--text-secondary);
}

.document-tab.active {
  background: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.document-tab .tab-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.document-tab .tab-status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.document-tab .tab-classification-badge {
  font-size: 10px;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: 4px;
  background-color: #3b82f6;
  color: white;
  flex-shrink: 0;
  white-space: nowrap;
  text-transform: capitalize;
  margin-left: 4px;
}

.document-tab .tab-name {
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.document-tab .tab-close {
  width: 16px;
  height: 16px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  opacity: 0;
  transition: all 0.15s ease;
}

.document-tab:hover .tab-close,
.document-tab.active .tab-close {
  opacity: 1;
}

.document-tab .tab-close:hover {
  background: rgba(165, 28, 48, 0.15);
  color: var(--crimson);
}

.document-tab.unsaved .tab-name::after {
  content: '•';
  margin-left: 4px;
  color: var(--crimson);
}

.tab-add-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px dashed var(--border-default);
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.tab-add-btn:hover {
  border-color: var(--border-strong);
  background: var(--bg-hover);
  color: var(--text-secondary);
}

/* Hide tabs bar when only one document (show on hover) */
.apprentice-editor-tabs.single-tab {
  opacity: 0.5;
  transition: opacity 0.2s ease;
}

.apprentice-editor-tabs.single-tab:hover {
  opacity: 1;
}

/* ==========================================
   SECONDARY TAB ROW (Shared Container)
   ========================================== */

.secondary-tabs-row {
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-default);
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height 0.3s ease-out, opacity 0.3s ease-out;
}

.secondary-tabs-row.hidden {
  max-height: 0 !important;
  opacity: 0 !important;
  display: none;
}

.secondary-tabs-row:not(.hidden) {
  max-height: 50px;
  opacity: 1;
}

.secondary-tabs-container {
  display: flex;
  gap: 2px;
  padding: var(--space-xs) var(--space-sm);
  min-height: 40px;
  align-items: center;
}

.secondary-tab {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: var(--font-size-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.secondary-tab:hover {
  background: var(--bg-hover);
  color: var(--text-secondary);
}

.secondary-tab.active {
  background: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.secondary-tab .tab-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.secondary-tab .tab-name {
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

/* =====================================================
   CHAT PANEL
   ===================================================== */
.apprentice-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.apprentice-message {
  max-width: 90%;
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-lg);
  line-height: 1.7;
  animation: messageSlideIn 0.3s ease;
}

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

.apprentice-message.user {
  background: var(--bg-surface);
  color: var(--text-primary);
  margin-left: auto;
  border-bottom-right-radius: var(--radius-sm);
}

.apprentice-message.assistant {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border-left: 3px solid var(--crimson);
  margin-right: auto;
  border-bottom-left-radius: var(--radius-sm);
}

.apprentice-message.assistant p {
  color: var(--text-secondary);
  margin-bottom: 0;
}

.apprentice-message.assistant p:not(:last-child) {
  margin-bottom: var(--space-md);
}

/* Typing indicator */
.apprentice-message.typing::after {
  content: '\u258C';
  color: var(--crimson);
  animation: blink 0.8s infinite;
  margin-left: 2px;
}

@keyframes blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

/* Adventure options */
.adventure-options {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-top: var(--space-lg);
}

.adventure-option {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
  color: var(--text-primary);
  font-size: var(--font-size-base);
  position: relative;
  overflow: hidden;

  /* Futuristic entrance animation */
  opacity: 0;
  transform: translateX(-20px);
  animation: optionSlideIn 0.4s ease-out forwards;
  animation-delay: var(--delay, 0s);

  /* Smooth hover transition */
  transition: background 0.2s, border-color 0.2s, transform 0.15s, box-shadow 0.2s;
}

@keyframes optionSlideIn {
  0% {
    opacity: 0;
    transform: translateX(-20px);
  }
  60% {
    opacity: 1;
    transform: translateX(4px);
  }
  100% {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Scan line effect on hover */
.adventure-option::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(165, 28, 48, 0.1),
    rgba(165, 28, 48, 0.2),
    rgba(165, 28, 48, 0.1),
    transparent
  );
  transition: left 0.5s ease;
}

.adventure-option:hover::before {
  left: 100%;
}

.adventure-option:hover {
  background: var(--crimson-subtle);
  border-color: var(--crimson);
  transform: translateX(4px);
  box-shadow: 0 0 20px rgba(165, 28, 48, 0.2), inset 0 0 20px rgba(165, 28, 48, 0.05);
}

.adventure-option:active {
  transform: translateX(2px);
  box-shadow: 0 0 10px rgba(165, 28, 48, 0.3);
}

.adventure-option .letter {
  display: none; /* Letter prefixes hidden for general options - email options use letters from backend */
}

.adventure-option .text {
  flex: 1;
  position: relative;
  z-index: 1;
}

/* Selected state - persistent after clicking */
.adventure-option.selected {
  background: var(--crimson-subtle);
  border-color: var(--crimson);
  box-shadow: 0 0 20px rgba(165, 28, 48, 0.3), inset 0 0 20px rgba(165, 28, 48, 0.1);
  cursor: default;
}

.adventure-option.selected::after {
  content: '\2713';
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  background: var(--crimson);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 12px;
  font-weight: bold;
  line-height: 1;
}

.adventure-option.selected::before {
  display: none; /* Override the scan line effect */
}

.adventure-option.selected:hover {
  transform: none; /* No hover transform when selected */
}

/* Disabled state for non-selected options after selection */
.adventure-option:disabled:not(.selected) {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.adventure-option:disabled:not(.selected):hover {
  background: var(--bg-surface);
  border-color: var(--border-default);
  transform: none;
  box-shadow: none;
}

/* Additional disabled state for coming soon options */
.adventure-option:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

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

/* =====================================================
   INPUT AREA
   ===================================================== */
.apprentice-input-area {
  padding: var(--space-md) var(--space-lg);
  background: var(--bg-elevated);
  border-top: 1px solid var(--border-subtle);
}

.apprentice-drop-zone {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  margin-bottom: var(--space-sm);
  background: var(--bg-deep);
  border: 2px solid var(--border-strong);
  border-radius: var(--radius-lg);
  min-height: 44px;
  transition: all var(--transition);
  cursor: pointer;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

.apprentice-drop-zone:hover {
  border-color: var(--crimson);
  background: var(--bg-surface);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3), 0 0 0 1px var(--crimson-subtle);
}

.apprentice-drop-zone.drag-over {
  border-color: var(--crimson);
  background: var(--crimson-subtle);
  box-shadow: var(--shadow-glow);
}

.apprentice-drop-zone-content {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.apprentice-drop-zone-text {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: var(--font-size-sm);
  color: var(--text-muted);
}

.apprentice-drop-zone-text svg {
  flex-shrink: 0;
}

.apprentice-drop-zone.has-files .apprentice-drop-zone-content {
  display: none;
}

.browse-btn {
  padding: var(--space-xs) var(--space-sm);
  background: var(--crimson);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-xs);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}

.browse-btn:hover {
  background: var(--crimson-hover);
}

.file-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
}

.file-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  background: var(--slate-dark);
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
}

.file-chip-remove {
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 50%;
  transition: all var(--transition);
}

.file-chip-remove:hover {
  background: var(--danger-subtle);
  color: var(--danger);
}

.apprentice-input-row {
  display: flex;
  gap: var(--space-sm);
}

.apprentice-input {
  flex: 1;
  padding: var(--space-md);
  background: var(--bg-deep);
  border: 2px solid var(--border-strong);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  font-size: var(--font-size-base);
  font-family: inherit;
  resize: none;
  min-height: 52px;
  max-height: 200px;
  transition: all var(--transition);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

.apprentice-input:focus {
  outline: none;
  border-color: var(--crimson);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3), var(--shadow-glow);
}

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

.apprentice-send-btn {
  width: 44px;
  height: 44px;
  padding: 0;
  background: var(--crimson);
  border: none;
  border-radius: var(--radius-lg);
  color: white;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.apprentice-send-btn:hover {
  background: var(--crimson-hover);
}

.apprentice-send-btn:active {
  transform: scale(0.98);
}

.apprentice-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* =====================================================
   EDITOR PANEL
   ===================================================== */
.apprentice-editor-header {
  /* Hidden - tabs already show document name, this was causing alignment issues */
  display: none;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-md) var(--space-lg);
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-subtle);
}

.apprentice-editor-title {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.apprentice-editor-title h3 {
  font-size: var(--font-size-base);
  font-weight: 500;
}

.profile-badge {
  font-size: var(--font-size-xs);
  padding: var(--space-xs) var(--space-sm);
  background: var(--crimson-subtle);
  color: var(--crimson-light);
  border-radius: var(--radius-full);
}

.apprentice-editor-actions {
  display: flex;
  gap: var(--space-sm);
}

.apprentice-editor-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.apprentice-editor-textarea {
  flex: 1;
  padding: var(--space-lg);
  background: var(--bg-deep);
  border: none;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
  line-height: 1.8;
  resize: none;
}

.apprentice-editor-textarea:focus {
  outline: none;
}

.apprentice-editor-textarea::placeholder {
  color: var(--text-muted);
}

.apprentice-editor-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-sm) var(--space-lg);
  background: var(--bg-primary);
  border-top: 1px solid var(--border-subtle);
  font-size: var(--font-size-sm);
  color: var(--text-muted);
}

.apprentice-editor-stats {
  display: flex;
  gap: var(--space-lg);
}

.apprentice-editor-status {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.apprentice-editor-status.streaming {
  color: var(--crimson);
}

.apprentice-editor-status.streaming::before {
  content: '';
  width: 8px;
  height: 8px;
  background: var(--crimson);
  border-radius: 50%;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Empty state */
.apprentice-editor-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  padding: var(--space-2xl);
  text-align: center;
}

.apprentice-editor-empty svg {
  width: 64px;
  height: 64px;
  margin-bottom: var(--space-lg);
  opacity: 0.3;
}

.apprentice-editor-empty h3 {
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
}

/* Matter Selection Button - 4x size of voice button */
.matter-select-button {
  width: 88px;
  height: 88px;
  padding: 0;
  background: var(--crimson);
  border: none;
  border-radius: calc(var(--radius-lg) * 2);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-lg);
  transition: all var(--transition);
  box-shadow: var(--shadow-sm);
  opacity: 0.85;
}

.matter-select-button:hover {
  background: var(--crimson-hover);
  box-shadow: var(--shadow-lg);
  opacity: 1;
  animation: matter-select-breathe 3s ease-in-out infinite;
}

@keyframes matter-select-breathe {
  0%, 100% {
    box-shadow: 0 4px 12px rgba(165, 28, 48, 0.3), 0 0 0 0 rgba(165, 28, 48, 0.3);
  }
  50% {
    box-shadow: 0 4px 12px rgba(165, 28, 48, 0.3), 0 0 0 12px rgba(165, 28, 48, 0);
  }
}

.matter-select-button:active {
  transform: scale(0.95);
}

.matter-select-button .book-icon {
  width: 36px;
  height: 36px;
  stroke: white;
  stroke-width: 2;
}

/* Transcript Microphone Button */
.transcript-mic-button {
  width: 88px;
  height: 88px;
  padding: 0;
  background: var(--crimson);
  border: none;
  border-radius: calc(var(--radius-lg) * 2);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-lg);
  transition: all var(--transition);
  box-shadow: var(--shadow-sm);
  opacity: 0.85;
}

.transcript-mic-button:hover {
  background: var(--crimson-hover);
  box-shadow: var(--shadow-lg);
  opacity: 1;
  animation: transcript-mic-breathe 3s ease-in-out infinite;
}

@keyframes transcript-mic-breathe {
  0%, 100% {
    box-shadow: 0 4px 12px rgba(165, 28, 48, 0.3), 0 0 0 0 rgba(165, 28, 48, 0.3);
  }
  50% {
    box-shadow: 0 4px 12px rgba(165, 28, 48, 0.3), 0 0 0 12px rgba(165, 28, 48, 0);
  }
}

.transcript-mic-button:active {
  transform: scale(0.95);
}

.transcript-mic-button.animating {
  animation: transcript-mic-travel 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  pointer-events: none;
}

@keyframes transcript-mic-travel {
  0% {
    transform: translate(0, 0) scale(1);
    opacity: 1;
  }
  100% {
    transform: translate(calc(50vw - 44px), calc(100vh - 200px)) scale(0.25);
    opacity: 0;
  }
}

.transcript-mic-button .mic-icon {
  width: 36px;
  height: 36px;
  stroke: white;
  stroke-width: 2;
  transform: translateY(2px);
}

/* Instructions Button */
.instructions-button {
  width: 88px;
  height: 88px;
  padding: 0;
  background: var(--crimson);
  border: none;
  border-radius: calc(var(--radius-lg) * 2);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-lg);
  transition: all var(--transition);
  box-shadow: var(--shadow-sm);
  opacity: 0.85;
}

.instructions-button:hover {
  background: var(--crimson-hover);
  box-shadow: var(--shadow-lg);
  opacity: 1;
  animation: instructions-breathe 3s ease-in-out infinite;
}

@keyframes instructions-breathe {
  0%, 100% {
    box-shadow: 0 4px 12px rgba(165, 28, 48, 0.3), 0 0 0 0 rgba(165, 28, 48, 0.3);
  }
  50% {
    box-shadow: 0 4px 12px rgba(165, 28, 48, 0.3), 0 0 0 12px rgba(165, 28, 48, 0);
  }
}

.instructions-button:active {
  transform: scale(0.95);
}

.instructions-button .instructions-icon {
  width: 36px;
  height: 36px;
  stroke: white;
  stroke-width: 2;
}

/* Text Paste Button */
.text-paste-button {
  width: 88px;
  height: 88px;
  padding: 0;
  background: var(--crimson);
  border: none;
  border-radius: calc(var(--radius-lg) * 2);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-lg);
  transition: all var(--transition);
  box-shadow: var(--shadow-sm);
  opacity: 0.85;
}

.text-paste-button:hover {
  background: var(--crimson-hover);
  box-shadow: var(--shadow-lg);
  opacity: 1;
  animation: text-paste-breathe 3s ease-in-out infinite;
}

@keyframes text-paste-breathe {
  0%, 100% {
    box-shadow: 0 4px 12px rgba(165, 28, 48, 0.3), 0 0 0 0 rgba(165, 28, 48, 0.3);
  }
  50% {
    box-shadow: 0 4px 12px rgba(165, 28, 48, 0.3), 0 0 0 12px rgba(165, 28, 48, 0);
  }
}

.text-paste-button:active {
  transform: scale(0.95);
}

.text-paste-button .paste-icon {
  width: 36px;
  height: 36px;
  stroke: white;
  stroke-width: 2;
}

/* Uploads Button */
.uploads-button {
  width: 88px;
  height: 88px;
  padding: 0;
  background: var(--crimson);
  border: none;
  border-radius: calc(var(--radius-lg) * 2);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-lg);
  transition: all var(--transition);
  box-shadow: var(--shadow-sm);
  opacity: 0.85;
}

.uploads-button:hover {
  background: var(--crimson-hover);
  box-shadow: var(--shadow-lg);
  opacity: 1;
  animation: uploads-breathe 3s ease-in-out infinite;
}

@keyframes uploads-breathe {
  0%, 100% {
    box-shadow: 0 4px 12px rgba(165, 28, 48, 0.3), 0 0 0 0 rgba(165, 28, 48, 0.3);
  }
  50% {
    box-shadow: 0 4px 12px rgba(165, 28, 48, 0.3), 0 0 0 12px rgba(165, 28, 48, 0);
  }
}

.uploads-button:active {
  transform: scale(0.95);
}

.uploads-button .upload-icon {
  width: 36px;
  height: 36px;
  stroke: white;
  stroke-width: 2;
}

/* Generic Empty State for Regular Document Tabs */
.generic-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  padding: var(--space-xl);
}

.generic-empty-state .empty-doc-icon {
  width: 64px;
  height: 64px;
  stroke: var(--text-tertiary);
  opacity: 0.5;
  margin-bottom: var(--space-sm);
}

.generic-empty-state h3 {
  color: var(--text-secondary);
  font-weight: 400;
  font-size: var(--font-size-lg);
  margin: 0;
}

/* Editor Toolbar - Edit/Preview toggle */
.editor-toolbar {
  display: flex;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-lg);
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-subtle);
}

.editor-mode-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: var(--font-size-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.editor-mode-btn:hover {
  background: var(--bg-hover);
  color: var(--text-secondary);
}

.editor-mode-btn.active {
  background: var(--bg-surface);
  border-color: var(--border-default);
  color: var(--text-primary);
}

.editor-mode-btn svg {
  opacity: 0.7;
}

.editor-mode-btn.active svg {
  opacity: 1;
}

/* Editor Preview Pane */
.editor-preview {
  flex: 1;
  padding: var(--space-lg);
  background: var(--bg-deep);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--font-size-base);
  line-height: 1.8;
  overflow-y: auto;
}

.editor-preview p {
  margin-bottom: 12pt;
}

.editor-preview p:last-child {
  margin-bottom: 0;
}

.editor-preview h1,
.editor-preview h2,
.editor-preview h3 {
  color: var(--text-primary);
  margin-top: var(--space-lg);
  margin-bottom: var(--space-md);
}

.editor-preview h1 {
  font-size: 1.5em;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: var(--space-sm);
}

.editor-preview h2 {
  font-size: 1.3em;
}

.editor-preview h3 {
  font-size: 1.1em;
}

.editor-preview strong {
  color: var(--text-primary);
  font-weight: 600;
}

.editor-preview em {
  font-style: italic;
}

.editor-preview ul,
.editor-preview ol {
  margin-left: var(--space-lg);
  margin-bottom: var(--space-md);
}

.editor-preview li {
  margin-bottom: var(--space-xs);
}

.editor-preview blockquote {
  border-left: 3px solid var(--crimson);
  padding-left: var(--space-md);
  margin: var(--space-md) 0;
  color: var(--text-secondary);
  font-style: italic;
}

/* =====================================================
   INSTRUCTIONS PANEL (Chat, Transcript, Text subpanels)
   ===================================================== */
.instructions-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
}

.instructions-panel.hidden {
  display: none;
}

.instructions-tab-content {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
}

.instructions-tab-content.hidden {
  display: none;
}

/* Chat subpanel */
#instructionsChat {
  display: flex;
  flex-direction: column;
  height: 100%;
}

#instructionsChat .apprentice-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-lg);
  scroll-behavior: smooth;
}

#instructionsChat .apprentice-input-area {
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-primary);
}

/* Transcript subpanel */
#instructionsTranscript {
  padding: var(--space-lg);
  overflow-y: auto;
}

.transcript-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--border-default);
}

.transcript-reader {
  flex: 1;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius);
  padding: var(--space-lg);
  margin-bottom: var(--space-lg);
  min-height: 400px;
  overflow-y: auto;
}

.transcript-panel-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: var(--space-md);
  border-top: 1px solid var(--border-default);
}

.transcript-stats {
  display: flex;
  gap: var(--space-lg);
  font-size: var(--font-size-sm);
  color: var(--text-muted);
}

.transcript-actions {
  display: flex;
  gap: var(--space-sm);
  align-items: center;
}

.transcript-record-btn {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  border: 2px solid var(--border-default);
  background: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.transcript-record-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}

.transcript-record-btn.recording {
  background: var(--crimson);
  border-color: var(--crimson);
  color: white;
  animation: pulse 2s ease-in-out infinite;
}

.transcript-record-btn .mic-icon {
  display: block;
}

.transcript-record-btn .pause-icon {
  display: none;
}

.transcript-record-btn.recording .mic-icon {
  display: none;
}

.transcript-record-btn.recording .pause-icon {
  display: block;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.transcript-placeholder {
  color: var(--text-muted);
  font-style: italic;
}

/* Text subpanel */
#instructionsText {
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  height: 100%;
}

.text-editor-container {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.text-editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--border-default);
}

.text-editor-header h3 {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.text-editor-hint {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
}

.text-editor-textarea {
  flex: 1;
  width: 100%;
  padding: var(--space-lg);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: var(--font-size-base);
  line-height: 1.6;
  resize: none;
  margin-bottom: var(--space-md);
}

.text-editor-textarea:focus {
  outline: none;
  border-color: var(--crimson);
  background: var(--bg-elevated);
}

.text-editor-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: var(--space-md);
  border-top: 1px solid var(--border-default);
}

.text-editor-stats {
  display: flex;
  gap: var(--space-lg);
  font-size: var(--font-size-sm);
  color: var(--text-muted);
}

.text-editor-actions {
  display: flex;
  gap: var(--space-sm);
}

/* =====================================================
   BUTTONS
   ===================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  font-size: var(--font-size-sm);
  font-weight: 500;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  border: 1px solid transparent;
}

.btn-primary {
  background: var(--crimson);
  color: white;
}

.btn-primary:hover {
  background: var(--crimson-hover);
}

.btn-secondary {
  background: var(--bg-surface);
  border-color: var(--border-default);
  color: var(--text-secondary);
}

.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
}

/* =====================================================
   FORMS (Login/Register)
   ===================================================== */
.auth-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
  background: var(--bg-deep);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  padding: var(--space-2xl);
  background: var(--bg-primary);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-lg);
}

.auth-logo {
  text-align: center;
  margin-bottom: var(--space-xl);
}

.auth-logo svg {
  width: 48px;
  height: 48px;
  fill: var(--crimson);
  margin-bottom: var(--space-md);
}

.auth-logo h1 {
  font-size: var(--font-size-xl);
  color: var(--text-primary);
  margin-bottom: var(--space-xs);
}

.auth-logo p {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  margin: 0;
}

.form-group {
  margin-bottom: var(--space-lg);
}

.form-group label {
  display: block;
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
}

.form-group input {
  width: 100%;
  padding: var(--space-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: var(--font-size-base);
  transition: all var(--transition);
}

.form-group input:focus {
  outline: none;
  border-color: var(--crimson);
  box-shadow: var(--shadow-glow);
}

.form-group input::placeholder {
  color: var(--text-muted);
}

.auth-submit {
  width: 100%;
  padding: var(--space-md);
  background: var(--crimson);
  border: none;
  border-radius: var(--radius);
  color: white;
  font-size: var(--font-size-base);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  margin-bottom: var(--space-lg);
}

.auth-submit:hover {
  background: var(--crimson-hover);
}

.auth-footer {
  text-align: center;
  font-size: var(--font-size-sm);
  color: var(--text-muted);
}

.auth-footer a {
  color: var(--crimson-light);
}

.message {
  padding: var(--space-md);
  border-radius: var(--radius);
  margin-bottom: var(--space-lg);
  font-size: var(--font-size-sm);
}

.message-error {
  background: var(--danger-subtle);
  color: var(--danger);
  border: 1px solid var(--danger);
}

.message-success {
  background: var(--success-subtle);
  color: var(--success);
  border: 1px solid var(--success);
}

/* =====================================================
   HISTORY PAGE
   ===================================================== */
.history-container {
  max-width: 800px;
  margin: 0 auto;
  padding: var(--space-2xl) var(--space-lg);
  margin-top: var(--header-height);
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-xl);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.history-item {
  display: block;
  padding: var(--space-lg);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  transition: all var(--transition);
  text-decoration: none;
}

.history-item:hover {
  border-color: var(--crimson);
  transform: translateX(4px);
}

.history-item-title {
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: var(--space-xs);
}

.history-item-preview {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  margin-bottom: var(--space-sm);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.history-item-meta {
  display: flex;
  gap: var(--space-md);
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

.history-empty {
  text-align: center;
  padding: var(--space-2xl);
  color: var(--text-muted);
}

/* =====================================================
   RESPONSIVE
   ===================================================== */
@media (max-width: 1400px) {
  :root {
    --chat-width: 35%;
    --editor-width: 65%;
    --mindmap-width: 0%;
  }
}

@media (max-width: 1024px) {
  :root {
    --chat-width: 35%;
    --editor-width: 65%;
    --mindmap-width: 0%;
  }

  .apprentice-mindmap-panel {
    display: none;
  }
}

@media (max-width: 768px) {
  .apprentice-main {
    flex-direction: column;
  }

  .apprentice-chat-panel,
  .apprentice-editor-panel {
    width: 100%;
    height: 50vh;
  }

  .apprentice-chat-panel {
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
  }

  .apprentice-mindmap-panel {
    display: none;
  }

  .apprentice-header-btn span {
    display: none;
  }

  .apprentice-user-name {
    display: none;
  }

  .adventure-option {
    padding: var(--space-sm) var(--space-md);
  }
}

@media (max-width: 480px) {
  .apprentice-header {
    padding: 0 var(--space-md);
  }

  .apprentice-title {
    display: none;
  }

  .apprentice-messages {
    padding: var(--space-md);
  }

  .apprentice-input-area {
    padding: var(--space-sm) var(--space-md);
  }
}

/* =====================================================
   LOADING STATES
   ===================================================== */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl);
  color: var(--text-muted);
}

.loading::after {
  content: '';
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-default);
  border-top-color: var(--crimson);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-left: var(--space-sm);
}

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

/* =====================================================
   THINKING INDICATOR & TYPING CURSOR
   ===================================================== */
.thinking-indicator {
  display: flex;
  gap: 4px;
  padding: 8px 0;
}

.thinking-indicator span {
  width: 8px;
  height: 8px;
  background: var(--crimson);
  border-radius: 50%;
  animation: thinking 1.4s ease-in-out infinite;
}

.thinking-indicator span:nth-child(2) {
  animation-delay: 0.2s;
}

.thinking-indicator span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes thinking {
  0%, 80%, 100% {
    opacity: 0.3;
    transform: scale(0.8);
  }
  40% {
    opacity: 1;
    transform: scale(1);
  }
}

.typing-cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--crimson);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: blink 0.8s ease-in-out infinite;
}

@keyframes blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

/* Markdown styles in messages */
.apprentice-message h1,
.apprentice-message h2,
.apprentice-message h3 {
  margin: 0.5em 0 0.3em 0;
  color: var(--text-primary);
}

.apprentice-message h1 { font-size: 1.4em; }
.apprentice-message h2 { font-size: 1.2em; }
.apprentice-message h3 { font-size: 1.1em; }

.apprentice-message strong {
  color: var(--text-primary);
  font-weight: 600;
}

.apprentice-message em {
  font-style: italic;
}

.apprentice-message p {
  margin: 0.5em 0;
}

.apprentice-message p:first-child {
  margin-top: 0;
}

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

.apprentice-message .error {
  color: var(--danger);
}

.apprentice-message .error-container {
  background: rgba(139, 0, 0, 0.1);
  border: 1px solid var(--danger);
  border-radius: 8px;
  padding: 1rem;
  margin: 0.5rem 0;
}

.apprentice-message .error-container .error {
  margin: 0 0 0.5rem 0;
  font-weight: 500;
}

.apprentice-message .error-help {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin: 0;
}

/* =====================================================
   OPUS STATUS BAR (Dual-Agent Architecture)
   ===================================================== */
.opus-status-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: linear-gradient(135deg, rgba(139, 0, 0, 0.08), rgba(139, 0, 0, 0.04));
  border: 1px solid rgba(139, 0, 0, 0.2);
  border-radius: 8px;
  margin: 0 16px 12px 16px;
  font-size: 0.9rem;
}

.opus-status-bar.hidden {
  display: none;
}

.opus-status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
}

.opus-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: opus-pulse 1.5s infinite;
}

.opus-status-bar.complete .opus-status-dot {
  background: #22c55e;
  animation: none;
}

.opus-status-bar.error .opus-status-dot {
  background: #ef4444;
  animation: none;
}

.opus-status-bar.waiting .opus-status-dot {
  background: #f59e0b;
  animation: opus-pulse 2s infinite;
}

@keyframes opus-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.9); }
}

.opus-status-text {
  color: var(--text-primary);
  font-weight: 500;
}

.opus-progress-detail {
  color: var(--text-secondary);
  font-size: 0.85rem;
  flex: 1;
}

.opus-status-action {
  padding: 4px 12px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.2s;
}

.opus-status-action:hover {
  background: var(--accent-hover);
}

.opus-status-action.hidden {
  display: none;
}

/* =====================================================
   UTILITIES
   ===================================================== */
.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* =====================================================
   HISTORY PAGE
   ===================================================== */
.history-main {
  padding: var(--spacing-lg);
  min-height: calc(100vh - 60px);
  background: var(--bg-deep);
}

.history-container {
  max-width: 800px;
  margin: 0 auto;
}

.history-search {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius);
  padding: var(--spacing-sm) var(--spacing-md);
  margin-bottom: var(--spacing-lg);
}

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

.history-search input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: var(--text-md);
  outline: none;
}

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

.history-list {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
}

.history-group {
  margin-bottom: var(--spacing-lg);
}

.history-group-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--spacing-sm);
  padding-left: var(--spacing-sm);
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: var(--spacing-md);
  text-decoration: none;
  transition: all var(--transition);
}

.history-item:hover {
  background: var(--bg-hover);
  border-color: var(--border-default);
}

.history-item-content {
  flex: 1;
  min-width: 0;
}

.history-item-title {
  color: var(--text-primary);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: var(--spacing-xs);
}

.history-item-meta {
  display: flex;
  gap: var(--spacing-md);
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.history-item-delete {
  background: transparent;
  border: none;
  padding: var(--spacing-xs);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  opacity: 0;
  transition: all var(--transition);
}

.history-item:hover .history-item-delete {
  opacity: 1;
}

.history-item-delete:hover {
  color: var(--danger);
  background: var(--danger-subtle);
}

.history-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--spacing-md);
  padding: var(--spacing-xl);
  color: var(--text-muted);
}

.history-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--spacing-md);
  padding: var(--spacing-xl) * 2;
  text-align: center;
}

.history-empty svg {
  width: 64px;
  height: 64px;
  color: var(--text-muted);
  opacity: 0.5;
}

.history-empty h3 {
  color: var(--text-primary);
  font-size: var(--text-lg);
  margin: 0;
}

.history-empty p {
  color: var(--text-muted);
  margin: 0;
}

.history-error {
  padding: var(--spacing-lg);
  text-align: center;
  color: var(--danger);
}

/* =====================================================
   WORKFLOW: THE GATHERING PANEL
   ===================================================== */
.gathering-panel {
  position: fixed;
  top: calc(var(--header-height) + var(--space-md));
  right: var(--space-md);
  width: 320px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 90;
  overflow: hidden;
  animation: panelSlideIn 0.3s ease-out;
}

@keyframes panelSlideIn {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.gathering-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  background: linear-gradient(135deg, var(--crimson) 0%, var(--crimson-hover) 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.gathering-title {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: white;
  text-transform: uppercase;
  letter-spacing: 0.15em;
}

.gathering-toggle {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.15);
  border: none;
  border-radius: var(--radius-sm);
  color: white;
  font-size: var(--font-size-lg);
  cursor: pointer;
  transition: background var(--transition);
}

.gathering-toggle:hover {
  background: rgba(255, 255, 255, 0.25);
}

.gathering-content {
  padding: var(--space-md);
  max-height: 400px;
  overflow-y: auto;
}

.gathering-panel.collapsed .gathering-content {
  display: none;
}

.gathering-panel.collapsed .gathering-toggle {
  transform: rotate(180deg);
}

/* Workflow name and progress */
.gathering-workflow-name {
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: var(--space-sm);
}

.gathering-progress {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}

.gathering-progress-bar {
  flex: 1;
  height: 6px;
  background: var(--bg-surface);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.gathering-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--crimson) 0%, var(--success) 100%);
  border-radius: var(--radius-full);
  transition: width 0.5s ease;
}

.gathering-progress-text {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  white-space: nowrap;
}

/* Document slots */
.gathering-slots {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.gathering-slot {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  transition: all var(--transition);
}

.gathering-slot.required {
  border-left: 3px solid var(--crimson);
}

.gathering-slot.filled {
  border-color: var(--success);
  background: var(--success-subtle);
}

.gathering-slot.filled.required {
  border-left-color: var(--success);
}

.gathering-slot-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-hover);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.gathering-slot.filled .gathering-slot-icon {
  background: var(--success);
  color: white;
}

.gathering-slot-icon svg {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
}

.gathering-slot.filled .gathering-slot-icon svg {
  color: white;
}

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

.gathering-slot-name {
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gathering-slot-status {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

.gathering-slot.filled .gathering-slot-status {
  color: var(--success);
}

.gathering-slot-action {
  padding: var(--space-xs) var(--space-sm);
  background: var(--crimson);
  border: none;
  border-radius: var(--radius-sm);
  color: white;
  font-size: var(--font-size-xs);
  cursor: pointer;
  transition: background var(--transition);
}

.gathering-slot-action:hover {
  background: var(--crimson-hover);
}

.gathering-slot.filled .gathering-slot-action {
  background: transparent;
  color: var(--text-muted);
  padding: var(--space-xs);
}

.gathering-slot.filled .gathering-slot-action:hover {
  color: var(--danger);
}

/* Gathering actions */
.gathering-actions {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-lg);
  padding-top: var(--space-md);
  border-top: 1px solid var(--border-subtle);
}

.gathering-actions .btn {
  flex: 1;
}

/* =====================================================
   WORKFLOW: DEFICIENCY CARDS
   ===================================================== */
.deficiency-container {
  padding: var(--space-md);
}

.deficiency-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-lg);
}

.deficiency-title {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--text-primary);
}

.deficiency-count {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  background: var(--bg-surface);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-full);
}

.deficiency-cards {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.deficiency-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all var(--transition);
}

.deficiency-card:hover {
  border-color: var(--border-strong);
}

.deficiency-card.selected {
  border-color: var(--crimson);
  box-shadow: 0 0 0 1px var(--crimson);
}

.deficiency-card.excluded {
  opacity: 0.5;
}

.deficiency-card-header {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  background: var(--bg-surface);
  cursor: pointer;
}

.deficiency-checkbox {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-deep);
  border: 2px solid var(--border-strong);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  transition: all var(--transition);
}

.deficiency-card.selected .deficiency-checkbox {
  background: var(--crimson);
  border-color: var(--crimson);
}

.deficiency-checkbox svg {
  width: 12px;
  height: 12px;
  color: white;
  opacity: 0;
}

.deficiency-card.selected .deficiency-checkbox svg {
  opacity: 1;
}

.deficiency-number {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--crimson);
  padding: var(--space-xs) var(--space-sm);
  background: var(--crimson-subtle);
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

.deficiency-summary {
  flex: 1;
  min-width: 0;
}

.deficiency-request-text {
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.deficiency-severity {
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: 500;
  text-transform: uppercase;
}

.deficiency-severity.high {
  background: var(--danger-subtle);
  color: var(--danger);
}

.deficiency-severity.medium {
  background: var(--warning-subtle);
  color: var(--warning);
}

.deficiency-severity.low {
  background: var(--info-subtle);
  color: var(--info);
}

.deficiency-expand {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: transform var(--transition);
}

.deficiency-card.expanded .deficiency-expand {
  transform: rotate(180deg);
}

/* Deficiency card body (collapsible) */
.deficiency-card-body {
  display: none;
  padding: var(--space-lg);
  border-top: 1px solid var(--border-subtle);
}

.deficiency-card.expanded .deficiency-card-body {
  display: block;
}

.deficiency-section {
  margin-bottom: var(--space-lg);
}

.deficiency-section:last-child {
  margin-bottom: 0;
}

.deficiency-section-title {
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-sm);
}

.deficiency-section-content {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  line-height: 1.6;
}

.deficiency-response-type {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  margin-right: var(--space-xs);
  margin-bottom: var(--space-xs);
}

.deficiency-objection {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  padding: var(--space-sm);
  background: var(--warning-subtle);
  border-radius: var(--radius);
  margin-bottom: var(--space-sm);
}

.deficiency-objection:last-child {
  margin-bottom: 0;
}

.deficiency-objection-icon {
  color: var(--warning);
  flex-shrink: 0;
}

.deficiency-objection-text {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

/* Deficiency actions */
.deficiency-bulk-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius);
  margin-bottom: var(--space-lg);
}

.deficiency-bulk-left {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.deficiency-select-all {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  cursor: pointer;
}

.deficiency-selected-count {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
}

/* =====================================================
   WORKFLOW: MOTION QUEUE
   ===================================================== */
.motion-queue {
  position: fixed;
  bottom: var(--space-lg);
  right: var(--space-lg);
  width: 360px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 85;
  overflow: hidden;
  animation: queueSlideUp 0.3s ease-out;
}

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

.motion-queue-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
}

.motion-queue-title {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-primary);
}

.motion-queue-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 var(--space-xs);
  background: var(--crimson);
  color: white;
  font-size: var(--font-size-xs);
  font-weight: 600;
  border-radius: var(--radius-full);
}

.motion-queue-minimize {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.motion-queue-minimize:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.motion-queue-items {
  max-height: 300px;
  overflow-y: auto;
}

.motion-queue-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--transition);
  cursor: pointer;
}

.motion-queue-item:last-child {
  border-bottom: none;
}

.motion-queue-item:hover {
  background: var(--bg-surface);
}

.motion-queue-item.active {
  background: var(--crimson-subtle);
  border-left: 3px solid var(--crimson);
}

.motion-queue-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface);
  border-radius: var(--radius);
  flex-shrink: 0;
}

.motion-queue-item.active .motion-queue-icon {
  background: var(--crimson);
  color: white;
}

.motion-queue-icon svg {
  width: 18px;
  height: 18px;
  color: var(--text-muted);
}

.motion-queue-item.active .motion-queue-icon svg {
  color: white;
}

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

.motion-queue-name {
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.motion-queue-type {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

.motion-queue-status {
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: 500;
}

.motion-queue-status.pending {
  background: var(--bg-surface);
  color: var(--text-muted);
}

.motion-queue-status.in-progress {
  background: var(--crimson-subtle);
  color: var(--crimson-light);
}

.motion-queue-status.ready {
  background: var(--success-subtle);
  color: var(--success);
}

.motion-queue-status.blocked {
  background: var(--warning-subtle);
  color: var(--warning);
}

/* Motion queue footer */
.motion-queue-footer {
  display: flex;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
}

.motion-queue-footer .btn {
  flex: 1;
}

/* Motion queue minimized state */
.motion-queue.minimized {
  width: auto;
  bottom: var(--space-md);
  right: var(--space-md);
}

.motion-queue.minimized .motion-queue-items,
.motion-queue.minimized .motion-queue-footer {
  display: none;
}

.motion-queue.minimized .motion-queue-header {
  border-bottom: none;
}

/* =====================================================
   WORKFLOW: PHASE INDICATORS
   ===================================================== */
.phase-indicator {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-lg);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-subtle);
}

.phase-step {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.phase-step-number {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface);
  border: 2px solid var(--border-default);
  border-radius: 50%;
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--text-muted);
}

.phase-step.completed .phase-step-number {
  background: var(--success);
  border-color: var(--success);
  color: white;
}

.phase-step.current .phase-step-number {
  background: var(--crimson);
  border-color: var(--crimson);
  color: white;
}

.phase-step-name {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

.phase-step.current .phase-step-name {
  color: var(--text-primary);
  font-weight: 500;
}

.phase-connector {
  flex: 1;
  height: 2px;
  background: var(--border-default);
  margin: 0 var(--space-xs);
}

.phase-connector.completed {
  background: var(--success);
}

/* =====================================================
   WORKFLOW: UPLOAD MODAL
   ===================================================== */
.upload-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: modalFadeIn 0.2s ease-out;
}

@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.upload-modal-content {
  width: 100%;
  max-width: 500px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.upload-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-lg);
  border-bottom: 1px solid var(--border-subtle);
}

.upload-modal-title {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--text-primary);
}

.upload-modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius);
  transition: all var(--transition);
}

.upload-modal-close:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
}

.upload-modal-body {
  padding: var(--space-lg);
}

.upload-drop-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xl);
  background: var(--bg-surface);
  border: 2px dashed var(--border-default);
  border-radius: var(--radius-lg);
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
}

.upload-drop-area:hover {
  border-color: var(--crimson);
  background: var(--crimson-subtle);
}

.upload-drop-area.drag-over {
  border-color: var(--crimson);
  background: var(--crimson-subtle);
  border-style: solid;
}

.upload-drop-icon {
  width: 48px;
  height: 48px;
  color: var(--text-muted);
  margin-bottom: var(--space-md);
}

.upload-drop-text {
  font-size: var(--font-size-base);
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
}

.upload-drop-hint {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
}

.upload-file-list {
  margin-top: var(--space-lg);
}

.upload-file-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--bg-surface);
  border-radius: var(--radius);
  margin-bottom: var(--space-sm);
}

.upload-file-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--crimson-subtle);
  border-radius: var(--radius);
  color: var(--crimson);
}

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

.upload-file-name {
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.upload-file-size {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

.upload-file-remove {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.upload-file-remove:hover {
  background: var(--danger-subtle);
  color: var(--danger);
}

.upload-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
  padding: var(--space-lg);
  border-top: 1px solid var(--border-subtle);
}

/* ============================================
   DETERMINISTIC FLOW ENGINE STYLES
   ============================================ */

.flow-step {
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.flow-step.completed {
  opacity: 0.7;
  pointer-events: none;
}

.flow-step.completed .adventure-options,
.flow-step.completed .flow-text-input,
.flow-step.completed .flow-matter-select,
.flow-step.completed .flow-file-upload,
.flow-step.completed .flow-actions {
  display: none;
}

.flow-question {
  font-size: var(--font-size-base);
  font-weight: 500;
  margin-bottom: var(--space-md);
}

.flow-selected-value {
  margin-top: var(--space-sm);
  padding: var(--space-xs) var(--space-sm);
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  display: inline-block;
}

.flow-text-input {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.flow-input,
.flow-textarea {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-deep);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: inherit;
  font-size: var(--font-size-sm);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.flow-input:focus,
.flow-textarea:focus {
  outline: none;
  border-color: var(--crimson);
  box-shadow: 0 0 0 2px var(--crimson-subtle);
}

.flow-textarea {
  resize: vertical;
  min-height: 80px;
}

.flow-actions {
  display: flex;
  gap: var(--space-sm);
  justify-content: flex-end;
  margin-top: var(--space-sm);
}

.flow-matter-select {
  margin-bottom: var(--space-sm);
}

.flow-matters-loading,
.flow-no-matters,
.flow-error {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  padding: var(--space-md);
  text-align: center;
}

.flow-matter-option {
  flex-direction: column;
  align-items: flex-start !important;
  gap: var(--space-xs);
}

.matter-client {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

/* Flow file upload */
.flow-file-upload {
  margin-bottom: var(--space-sm);
}

.flow-drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-lg);
  border: 2px dashed var(--border-default);
  border-radius: var(--radius-md);
  background: var(--bg-deep);
  cursor: pointer;
  transition: all 0.2s ease;
}

.flow-drop-zone:hover,
.flow-drop-zone.drag-over {
  border-color: var(--crimson);
  background: var(--crimson-subtle);
}

.flow-drop-zone svg {
  color: var(--text-muted);
}

.flow-drop-zone span {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
}

.flow-file-input {
  display: none;
}

.flow-file-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  margin-top: var(--space-sm);
}

/* Flow summary */
.flow-summary {
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
}

.flow-summary h3 {
  font-size: var(--font-size-lg);
  font-weight: 600;
  margin-bottom: var(--space-md);
  color: var(--text-primary);
}

.flow-summary-content {
  background: var(--bg-deep);
  padding: var(--space-md);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-md);
}

.flow-summary-content p {
  margin: var(--space-xs) 0;
  font-size: var(--font-size-sm);
}

.flow-actions-final {
  justify-content: flex-end;
}

.flow-submit.primary {
  background: var(--crimson);
  border-color: var(--crimson);
}

.flow-submit.primary:hover {
  background: var(--crimson-dark);
  border-color: var(--crimson-dark);
}

/* ============================================
   MIND MAP PANEL
   ============================================ */

.apprentice-mindmap-panel {
  /* Hidden for redesign - deterministic flow system replaces AI-driven navigation */
  display: none !important;
  width: var(--mindmap-width);
  border-left: 1px solid var(--border-subtle);
  background: var(--bg-deep);
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.apprentice-mindmap-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-primary);
  flex-shrink: 0;
}

.apprentice-mindmap-header h4 {
  margin: 0;
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-primary);
}

.apprentice-mindmap-actions {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.apprentice-mindmap-hint {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

.apprentice-mindmap-content {
  padding: var(--space-sm);
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* Mind Map Footer - matches document panel footer */
.apprentice-mindmap-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-sm) var(--space-lg);
  background: var(--bg-primary);
  border-top: 1px solid var(--border-subtle);
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  flex-shrink: 0;
}

.mindmap-export-actions {
  display: flex;
  gap: var(--space-sm);
}

/* Mind Map Empty State */
.mindmap-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl);
  text-align: center;
  color: var(--text-muted);
}

.mindmap-empty-icon {
  width: 48px;
  height: 48px;
  margin-bottom: var(--space-md);
  opacity: 0.5;
}

.mindmap-empty-state p {
  margin: 0 0 var(--space-sm);
  font-size: var(--font-size-sm);
}

.mindmap-empty-hint {
  font-size: var(--font-size-xs);
  color: var(--text-disabled);
  margin-bottom: var(--space-md);
}

.mindmap-empty-hint kbd {
  display: inline-block;
  padding: 2px 6px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  margin: 0 2px;
}

/* Mind Map Node Styling */
.mindmap-node {
  padding: var(--space-xs) var(--space-sm);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
  user-select: none;
}

.mindmap-node:hover {
  background: var(--bg-hover);
}

.mindmap-node.selected {
  background: var(--crimson-subtle);
}

.mindmap-toggle {
  display: inline-block;
  width: 16px;
  text-align: center;
  font-family: monospace;
  color: var(--text-muted);
  cursor: pointer;
}

.mindmap-toggle:hover {
  color: var(--text-primary);
}

.mindmap-icon {
  margin-right: var(--space-xs);
}

.mindmap-label {
  outline: none;
  padding: 1px 2px;
  border-radius: 2px;
}

.mindmap-label:focus {
  background: var(--bg-surface);
  box-shadow: 0 0 0 1px var(--border-default);
}

.mindmap-ai-badge {
  font-size: 0.65rem;
  background: var(--crimson);
  color: white;
  padding: 1px 4px;
  border-radius: 3px;
  margin-left: var(--space-xs);
  vertical-align: middle;
}

.mindmap-children {
  margin-left: 20px;
  border-left: 1px dashed var(--border-subtle);
  padding-left: var(--space-sm);
}

/* Node Type Colors - Icon and Background */
.mindmap-node[data-type="party"] {
  background: rgba(59, 130, 246, 0.08);
}
.mindmap-node[data-type="party"] .mindmap-icon {
  color: #3b82f6;
}
.mindmap-node[data-type="party"]:hover {
  background: rgba(59, 130, 246, 0.15);
}

.mindmap-node[data-type="goal"] {
  background: rgba(16, 185, 129, 0.08);
}
.mindmap-node[data-type="goal"] .mindmap-icon {
  color: #10b981;
}
.mindmap-node[data-type="goal"]:hover {
  background: rgba(16, 185, 129, 0.15);
}

.mindmap-node[data-type="fact"] {
  background: rgba(245, 158, 11, 0.08);
}
.mindmap-node[data-type="fact"] .mindmap-icon {
  color: #f59e0b;
}
.mindmap-node[data-type="fact"]:hover {
  background: rgba(245, 158, 11, 0.15);
}

.mindmap-node[data-type="issue"] {
  background: rgba(139, 92, 246, 0.08);
}
.mindmap-node[data-type="issue"] .mindmap-icon {
  color: #8b5cf6;
}
.mindmap-node[data-type="issue"]:hover {
  background: rgba(139, 92, 246, 0.15);
}

.mindmap-node[data-type="case"] .mindmap-icon {
  color: var(--crimson);
}

.mindmap-node[data-type="custom"] {
  background: rgba(100, 100, 100, 0.08);
}
.mindmap-node[data-type="custom"]:hover {
  background: rgba(100, 100, 100, 0.15);
}

/* ============================================
   VOICE INPUT BUTTON
   ============================================ */

.apprentice-voice-btn {
  position: relative;
  width: 44px;
  height: 44px;
  padding: 0;
  background: var(--crimson);
  border: none;
  border-radius: var(--radius-lg);
  color: white;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.apprentice-voice-btn:hover {
  background: var(--crimson-hover);
  box-shadow: var(--shadow);
}

.apprentice-voice-btn:active {
  transform: scale(0.95);
}

/* Breathing animation when idle - invites usage */
.apprentice-voice-btn:not(.recording):not(:disabled) {
  animation: voice-breathe 3s ease-in-out infinite;
}

@keyframes voice-breathe {
  0%, 100% { box-shadow: 0 0 0 0 rgba(165, 28, 48, 0.3); }
  50% { box-shadow: 0 0 0 6px rgba(165, 28, 48, 0); }
}

/* First-time discovery indicator */
.apprentice-voice-btn.discovery::after {
  content: '';
  position: absolute;
  top: -4px;
  right: -4px;
  width: 10px;
  height: 10px;
  background: var(--success);
  border-radius: 50%;
  border: 2px solid var(--bg-elevated);
}

/* Recording state */
.apprentice-voice-btn.recording {
  background: var(--crimson-light);
  animation: voice-pulse 1.5s ease-in-out infinite;
}

@keyframes voice-pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(165, 28, 48, 0.6);
  }
  50% {
    box-shadow: 0 0 0 14px rgba(165, 28, 48, 0);
  }
}

/* Disabled state */
.apprentice-voice-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.apprentice-voice-btn:disabled:hover {
  background: var(--crimson);
  box-shadow: var(--shadow-sm);
  transform: none;
}

/* Small variant for revision input */
.apprentice-voice-btn.small {
  width: 32px;
  height: 32px;
}

/* Unsupported browser state */
.apprentice-voice-btn.unsupported {
  display: none;
}

/* Voice Active Input - Visual distinction during recording */
.apprentice-input.voice-active {
  border-color: var(--crimson);
  box-shadow: 0 0 0 3px rgba(165, 28, 48, 0.15), inset 0 2px 8px rgba(0, 0, 0, 0.08);
  background: linear-gradient(to bottom, rgba(165, 28, 48, 0.03), transparent);
}

.apprentice-input.voice-active::placeholder {
  color: var(--crimson);
  opacity: 0.8;
}

/* Refining state - subtle animation while Claude cleans transcript */
.apprentice-input.refining {
  background: linear-gradient(90deg,
    var(--bg-primary) 0%,
    rgba(165, 28, 48, 0.05) 50%,
    var(--bg-primary) 100%);
  background-size: 200% 100%;
  animation: refiningShimmer 1.5s ease-in-out infinite;
}

@keyframes refiningShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Refined transition - brief highlight when text changes */
.apprentice-input.refined-transition {
  animation: refinedFlash 0.5s ease-out;
}

@keyframes refinedFlash {
  0% {
    background-color: rgba(34, 197, 94, 0.15);
    border-color: rgba(34, 197, 94, 0.5);
  }
  100% {
    background-color: var(--bg-primary);
    border-color: var(--border-default);
  }
}

/* ==========================================
   Voice Transcript Box
   ========================================== */
.apprentice-transcript-box {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-deep);
  border: 2px solid var(--border-strong);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-sm);
  min-height: 44px;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.apprentice-transcript-box.has-content,
.apprentice-transcript-box:focus-within {
  border-color: var(--crimson);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3), var(--shadow-glow);
}

.transcript-text {
  flex: 1;
  color: var(--text-muted);
  font-size: 0.9rem;
  white-space: pre-wrap;
  max-height: 100px;
  overflow-y: auto;
  line-height: 1.4;
}

.transcript-text.has-content {
  color: var(--text-primary);
}

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

/* Button group container */
.transcript-actions {
  display: flex;
  gap: var(--space-xs);
  flex-shrink: 0;
}

.transcript-action-btn {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.transcript-action-btn:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border-color: var(--border-default);
}

.transcript-action-btn:active {
  transform: scale(0.95);
}

.transcript-action-btn.cleaning {
  background: var(--crimson);
  color: white;
  border-color: var(--crimson);
  animation: pulse 1.5s infinite;
}

/* Legacy button classes for backwards compatibility */
.transcript-mic-btn,
.transcript-copy-btn {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.transcript-mic-btn:hover,
.transcript-copy-btn:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border-color: var(--border-default);
}

.transcript-mic-btn.recording {
  background: var(--crimson);
  color: white;
  border-color: var(--crimson);
  animation: pulse 1.5s infinite;
}

.transcript-copy-btn:active {
  transform: scale(0.95);
}

/* Refining state for transcript text */
.transcript-text.refining {
  color: var(--text-muted);
  animation: textPulse 1s ease-in-out infinite;
}

@keyframes textPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ==========================================
   Main Panel Tabs (Editor / Transcript)
   ========================================== */
.editor-main-tabs {
  display: flex;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-deep);
  border-bottom: 1px solid var(--border-subtle);
}

.editor-main-tab {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.editor-main-tab:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.editor-main-tab.active {
  background: var(--bg-primary);
  border-color: var(--border-default);
  color: var(--text-primary);
}

.editor-main-tab svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* Editor Panel Wrapper (shown when Editor tab is active) */
.editor-panel-wrapper {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.editor-panel-wrapper.hidden {
  display: none;
}

/* ==========================================
   Transcript Panel (Right Side)
   ========================================== */
.transcript-panel-content {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  background: var(--bg-surface);
}

.transcript-panel-content.hidden {
  display: none;
}

.transcript-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-primary);
}

.transcript-panel-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.transcript-phase-badge {
  padding: var(--space-xs) var(--space-sm);
  background: var(--crimson);
  color: white;
  border-radius: var(--radius-sm);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.transcript-phase-badge.feedback {
  background: var(--accent-blue);
}

/* Transcript Reader - shows full content */
.transcript-reader {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-lg);
  background: var(--bg-deep);
}

.transcript-reader-content {
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--text-primary);
  white-space: pre-wrap;
}

.transcript-reader-content p {
  margin: 0 0 var(--space-md) 0;
}

.transcript-reader-content .transcript-placeholder {
  color: var(--text-muted);
  font-style: italic;
}

/* Real-time cursor effect while recording */
.transcript-reader-content.recording p:last-child::after {
  content: '|';
  animation: blink-cursor 0.7s infinite;
  color: var(--crimson);
  font-weight: bold;
}

@keyframes blink-cursor {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

/* Transcript Panel Footer */
.transcript-panel-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-sm) var(--space-lg);
  background: var(--bg-primary);
  border-top: 1px solid var(--border-subtle);
}

.transcript-stats {
  display: flex;
  gap: var(--space-md);
  color: var(--text-muted);
  font-size: 0.8rem;
}

.transcript-actions {
  display: flex;
  gap: var(--space-sm);
  align-items: center;
}

/* ==========================================
   Transcript Record Button - 3 States
   ========================================== */
.transcript-record-btn {
  width: 44px;
  height: 44px;
  padding: 0;
  border: none;
  border-radius: var(--radius-lg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

/* State 1: Off (gray) */
.transcript-record-btn.off {
  background: var(--bg-secondary);
  color: var(--text-secondary);
  border: 2px solid var(--border-default);
}

.transcript-record-btn.off:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--crimson);
}

/* State 2: Paused (neutral with visible icon) */
.transcript-record-btn.paused {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 2px solid var(--border-strong);
}

.transcript-record-btn.paused:hover {
  background: var(--crimson);
  color: white;
  border-color: var(--crimson);
}

/* State 3: Recording (red + flashing animation) */
.transcript-record-btn.recording {
  background: var(--crimson);
  color: white;
  border: 2px solid var(--crimson);
  animation: transcript-record-pulse 1.5s ease-in-out infinite;
}

@keyframes transcript-record-pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(165, 28, 48, 0.6);
  }
  50% {
    box-shadow: 0 0 0 12px rgba(165, 28, 48, 0);
  }
}

.transcript-record-btn.recording:hover {
  animation: none;
  background: var(--crimson-light);
}

/* Icon visibility toggle */
.transcript-record-btn .hidden {
  display: none;
}

.transcript-record-btn svg {
  width: 18px;
  height: 18px;
}

/* ==========================================
   Microphone Permission Modal
   ========================================== */
.mic-permission-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: fadeIn 0.2s ease-out;
}

.mic-permission-content {
  background: var(--bg-primary);
  border-radius: 16px;
  padding: var(--space-xl);
  max-width: 400px;
  width: 90%;
  text-align: center;
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--border-subtle);
}

.mic-permission-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto var(--space-lg);
  background: rgba(165, 28, 48, 0.1);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mic-permission-icon svg {
  stroke: var(--crimson);
}

.mic-permission-content h3 {
  margin: 0 0 var(--space-sm);
  color: var(--text-primary);
  font-size: 1.25rem;
}

.mic-permission-content p {
  margin: 0 0 var(--space-lg);
  color: var(--text-secondary);
  line-height: 1.5;
}

.mic-permission-steps {
  background: var(--bg-surface);
  border-radius: 8px;
  padding: var(--space-md);
  margin-bottom: var(--space-lg);
  text-align: left;
}

.mic-permission-steps p {
  margin: 0 0 var(--space-xs);
  font-size: var(--font-size-sm);
}

.mic-permission-steps ol {
  margin: 0;
  padding-left: var(--space-lg);
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

.mic-permission-steps li {
  margin-bottom: var(--space-xs);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ==========================================
   Email Triage Dashboard Styles
   ========================================== */

.email-triage-dashboard {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.triage-category {
  margin-bottom: var(--space-sm);
}

.triage-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-weight: 600;
  padding: var(--space-sm) 0;
  cursor: default;
}

details.triage-category .triage-header {
  cursor: pointer;
}

.triage-icon {
  font-size: 1rem;
}

.triage-title {
  font-size: var(--font-size-sm);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.triage-count {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  font-weight: 400;
}

.triage-emails {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  padding-left: var(--space-lg);
}

.triage-emails.collapsed {
  display: none;
}

/* Email option styling by urgency */
.email-option.email-urgent {
  border-left: 4px solid #ef4444;
}

.email-option.email-needs-response {
  border-left: 4px solid #f59e0b;
}

.email-option.email-fyi {
  border-left: 4px solid #3b82f6;
}

.email-option.email-ignore {
  border-left: 4px solid #9ca3af;
  opacity: 0.7;
}

.email-option:hover {
  opacity: 1;
}

.email-hint {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  margin-top: var(--space-md);
}

/* ==========================================
   Email Abstraction View Styles
   ========================================== */

.email-abstraction {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
}

.email-abstraction-header {
  border-bottom: 1px solid var(--border-color);
  padding-bottom: var(--space-md);
  margin-bottom: var(--space-md);
}

.email-meta > div {
  margin-bottom: var(--space-xs);
  font-size: var(--font-size-sm);
}

.email-meta strong {
  color: var(--text-muted);
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.email-abstraction-body {
  margin-bottom: var(--space-md);
}

.email-context,
.email-action {
  margin-bottom: var(--space-md);
}

.email-context strong,
.email-action strong {
  display: block;
  color: var(--text-muted);
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-xs);
}

.email-context p,
.email-action p {
  margin: 0;
  color: var(--text-primary);
  line-height: 1.6;
}

.email-action {
  background: rgba(245, 158, 11, 0.1);
  padding: var(--space-sm);
  border-radius: var(--radius-md);
  border-left: 3px solid #f59e0b;
}

/* Reveal original email */
.email-reveal {
  margin: var(--space-md) 0;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
}

.email-reveal summary {
  cursor: pointer;
  padding: var(--space-sm) var(--space-md);
  color: var(--text-muted);
  font-size: var(--font-size-sm);
  user-select: none;
}

.email-reveal summary:hover {
  color: var(--text-primary);
}

.email-reveal[open] summary {
  border-bottom: 1px solid var(--border-color);
}

.email-raw-content {
  padding: var(--space-md);
  max-height: 300px;
  overflow-y: auto;
}

.email-raw-content pre {
  margin: 0;
  white-space: pre-wrap;
  word-wrap: break-word;
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  font-family: inherit;
}

.email-raw-content .loading-text {
  color: var(--text-muted);
  font-style: italic;
}

/* Response instruction input */
.email-response-prompt {
  margin-top: var(--space-lg);
  padding-top: var(--space-md);
  border-top: 1px solid var(--border-color);
}

.email-response-prompt label {
  display: block;
  margin-bottom: var(--space-sm);
  color: var(--text-primary);
}

.email-instruction-input {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: var(--font-size-sm);
  font-family: inherit;
  resize: vertical;
  margin-bottom: var(--space-sm);
}

.email-instruction-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.email-instruction-input::placeholder {
  color: var(--text-muted);
}

.email-draft-btn {
  width: 100%;
}

/* ==========================================
   Email Side Panel
   ========================================== */

.email-side-panel {
  position: fixed;
  right: 0;
  top: 56px;
  bottom: 0;
  width: 400px;
  max-width: 90vw;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transform: translateX(0);
  transition: transform 0.3s ease;
}

.email-side-panel.hidden {
  transform: translateX(100%);
  pointer-events: none;
}

.email-side-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-elevated);
}

.email-side-panel-tabs {
  display: flex;
  gap: var(--space-xs);
}

.email-side-tab {
  padding: var(--space-xs) var(--space-md);
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: var(--font-size-sm);
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius);
  transition: all var(--transition);
}

.email-side-tab:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.email-side-tab.active {
  background: var(--primary);
  color: white;
}

.email-side-panel-close {
  padding: var(--space-xs);
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.email-side-panel-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.email-side-panel-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-md);
}

/* Email Thread View */
.email-thread-view {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.email-thread-message {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  border: 1px solid var(--border-color);
}

.email-thread-message.current {
  border-color: var(--primary);
  background: var(--bg-elevated);
}

.email-thread-message-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--space-sm);
}

.email-thread-from {
  font-weight: 600;
  color: var(--text-primary);
  font-size: var(--font-size-sm);
}

.email-thread-date {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

.email-thread-subject {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
}

.email-thread-body {
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  line-height: 1.6;
  white-space: pre-wrap;
  max-height: 200px;
  overflow-y: auto;
}

.email-thread-body.expanded {
  max-height: none;
}

.email-thread-expand {
  margin-top: var(--space-sm);
  padding: var(--space-xs) var(--space-sm);
  border: none;
  background: transparent;
  color: var(--primary);
  font-size: var(--font-size-xs);
  cursor: pointer;
}

.email-thread-expand:hover {
  text-decoration: underline;
}

/* Email Attachments View */
.email-attachments-view {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.email-attachment-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
}

.email-attachment-item:hover {
  background: var(--bg-hover);
  border-color: var(--primary);
}

.email-attachment-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-tertiary);
  border-radius: var(--radius);
  color: var(--text-muted);
}

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

.email-attachment-name {
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.email-attachment-size {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

.email-no-attachments {
  text-align: center;
  padding: var(--space-xl);
  color: var(--text-muted);
  font-size: var(--font-size-sm);
}

/* ==========================================
   User Portal Specific Styles
   ========================================== */

.user-content-section {
  padding: var(--space-xl);
  height: 100%;
  overflow-y: auto;
}

.coming-soon-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  padding: var(--space-xl);
}

.coming-soon-screen svg {
  width: 80px;
  height: 80px;
  stroke: var(--text-tertiary);
  margin-bottom: var(--space-lg);
  opacity: 0.5;
}

.coming-soon-screen h2 {
  font-size: var(--font-size-xl);
  color: var(--text-primary);
  margin-bottom: var(--space-sm);
}

.coming-soon-screen p {
  font-size: var(--font-size-md);
  color: var(--text-secondary);
  margin-bottom: var(--space-xs);
}

/* ==============================================================================
   CASE FILE VIEWER - Redesigned with Dark Theme
   ============================================================================== */

/* Before Case Selection */
.case-file-before-selection {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 400px;
}

.case-file-book-button {
  background: none;
  border: none;
  cursor: pointer;
  text-align: center;
  padding: 40px;
  transition: transform 0.2s ease;
  color: var(--text-secondary);
}

.case-file-book-button:hover {
  transform: scale(1.05);
  color: var(--text-primary);
}

.case-file-book-button svg {
  color: var(--crimson);
  margin-bottom: 20px;
}

.case-file-book-button h2 {
  font-size: 24px;
  margin: 0 0 8px 0;
  color: var(--text-primary);
}

.case-file-book-button p {
  font-size: 14px;
  margin: 0;
  color: var(--text-secondary);
}

/* ==========================================
   CASE FILE PANEL (Static Structure)
   ========================================== */

.case-file-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--bg-deep);
}

.case-file-panel.hidden {
  display: none;
}

/* Case File Empty State (Cover Page) */
.case-file-empty-state {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-deep);
  z-index: 10;
  transition: opacity 0.2s ease-out;
}

.case-file-empty-state.hidden {
  opacity: 0;
  pointer-events: none;
  z-index: -1;
}

.case-file-book-button {
  background: none;
  border: none;
  cursor: pointer;
  text-align: center;
  padding: 40px;
  transition: transform 0.2s ease;
  color: var(--text-secondary);
}

.case-file-book-button:hover {
  transform: scale(1.05);
  color: var(--text-primary);
}

.case-file-book-button svg {
  color: var(--crimson);
  margin-bottom: 20px;
}

.case-file-book-button h2 {
  font-size: 24px;
  margin: 0 0 8px 0;
  color: var(--text-primary);
}

.case-file-book-button p {
  font-size: 14px;
  margin: 0;
  color: var(--text-secondary);
}

/* Case Header */
.case-file-header {
  padding: 20px 24px;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-default);
}

.case-file-header-left {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.case-file-case-name {
  font-size: 24px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.case-file-meta {
  display: flex;
  gap: 12px;
  align-items: center;
  font-size: 14px;
  color: var(--text-secondary);
}

.case-file-meta .case-number,
.case-file-meta .client-name {
  color: var(--text-secondary);
}

/* Case File Tab Content Panels */
.case-file-tab-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  background: var(--bg-deep);
  transition: opacity 0.15s ease-out;
}

.case-file-tab-content.hidden {
  display: none;
}

/* Loading State */
.case-file-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 400px;
  color: var(--text-secondary);
}

.loading-spinner {
  width: 48px;
  height: 48px;
  margin-bottom: 16px;
}

.loading-spinner svg {
  width: 100%;
  height: 100%;
  animation: spin 1s linear infinite;
}

.loading-spinner circle {
  stroke: var(--crimson);
  stroke-linecap: round;
  stroke-dasharray: 1, 150;
  stroke-dashoffset: 0;
  animation: dash 1.5s ease-in-out infinite;
}

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

@keyframes dash {
  0% { stroke-dasharray: 1, 150; stroke-dashoffset: 0; }
  50% { stroke-dasharray: 90, 150; stroke-dashoffset: -35; }
  100% { stroke-dasharray: 90, 150; stroke-dashoffset: -124; }
}

/* Error State */
.case-file-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 400px;
  color: var(--text-secondary);
  text-align: center;
  padding: 24px;
}

.case-file-error svg {
  color: var(--crimson);
  margin-bottom: 16px;
}

.case-file-error h3 {
  margin: 0 0 8px 0;
  color: var(--text-primary);
}

.case-file-error p {
  margin: 0;
  font-size: 14px;
}

/* ==============================================================================
   OVERVIEW TAB
   ============================================================================== */

.overview-tab {
  display: flex;
  flex-direction: column;
  gap: 24px;
  max-width: 1200px;
}

.overview-section {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 8px;
  padding: 20px;
}

.overview-section h3 {
  margin: 0 0 16px 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

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

.section-header h3 {
  margin: 0;
}

.btn-icon {
  background: none;
  border: 1px solid var(--border-default);
  padding: 6px;
  border-radius: 4px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:hover {
  background: var(--bg-elevated);
  border-color: var(--crimson);
  color: var(--crimson);
}

/* Case Metadata */
.metadata-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.metadata-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.metadata-item label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.metadata-value {
  font-size: 14px;
  color: var(--text-primary);
}

/* Status Badge */
.status-badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  text-transform: capitalize;
}

.status-badge.status-active {
  background: rgba(34, 197, 94, 0.1);
  color: #22c55e;
}

.status-badge.status-pending {
  background: rgba(234, 179, 8, 0.1);
  color: #eab308;
}

.status-badge.status-complete,
.status-badge.status-responded {
  background: rgba(59, 130, 246, 0.1);
  color: #3b82f6;
}

.status-badge.status-overdue {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

.status-badge.status-served {
  background: rgba(168, 85, 247, 0.1);
  color: #a855f7;
}

/* Parties Section */
.party-role-group {
  margin-bottom: 16px;
}

.party-role-group:last-child {
  margin-bottom: 0;
}

.party-role-group h4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 0 0 8px 0;
  text-transform: capitalize;
}

.party-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.party-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.party-name-link {
  color: var(--crimson);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s ease;
}

.party-name-link:hover {
  color: #c52341;
  text-decoration: underline;
}

.party-attorney {
  font-size: 13px;
  color: var(--text-secondary);
  padding-left: 12px;
}

/* Claims and Narrative Content */
.claims-content,
.narrative-content {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary);
  white-space: pre-wrap;
}

.claims-content.needs-dev,
.narrative-content.needs-dev {
  color: var(--text-muted);
  font-style: italic;
}

/* Recent Activity */
.activity-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.activity-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-default);
}

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

.activity-type {
  font-size: 12px;
  font-weight: 600;
  color: var(--crimson);
  text-transform: uppercase;
  min-width: 80px;
}

.activity-title {
  flex: 1;
  font-size: 14px;
  color: var(--text-primary);
}

.activity-time {
  font-size: 12px;
  color: var(--text-muted);
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-style: italic;
}

/* ==============================================================================
   FACTS TAB
   ============================================================================== */

.facts-tab,
.evidence-tab,
.discovery-tab {
  max-width: 1200px;
}

.tab-header {
  margin-bottom: 24px;
}

.tab-header h2 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 4px 0;
}

.tab-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0;
}

.facts-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.fact-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-left: 3px solid var(--crimson);
  border-radius: 6px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.fact-date {
  font-size: 12px;
  font-weight: 600;
  color: var(--crimson);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.fact-statement {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary);
}

.fact-source {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}

/* ==============================================================================
   EVIDENCE TAB
   ============================================================================== */

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

.evidence-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 6px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.evidence-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 8px;
}

.evidence-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}

.evidence-exhibit {
  font-size: 12px;
  padding: 2px 8px;
  background: rgba(165, 28, 48, 0.1);
  color: var(--crimson);
  border-radius: 4px;
  white-space: nowrap;
}

.evidence-type {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: capitalize;
}

.evidence-summary {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-secondary);
}

.btn-secondary {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  padding: 8px 16px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
}

.btn-secondary:hover {
  background: var(--bg-surface);
  border-color: var(--crimson);
  color: var(--crimson);
}

/* ==============================================================================
   DISCOVERY TAB
   ============================================================================== */

.discovery-group {
  margin-bottom: 32px;
}

.discovery-group:last-child {
  margin-bottom: 0;
}

.discovery-group-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 16px 0;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-default);
}

.discovery-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 6px;
  padding: 16px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.discovery-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.discovery-number {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.discovery-modules {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-secondary);
  background: var(--bg-elevated);
  padding: 8px 12px;
  border-radius: 4px;
}

.discovery-modules strong {
  color: var(--crimson);
}

.discovery-parties {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--text-secondary);
}

.discovery-parties strong {
  color: var(--text-primary);
  font-weight: 500;
}

.discovery-date {
  font-size: 12px;
  color: var(--text-muted);
}

.discovery-date strong {
  color: var(--text-secondary);
  font-weight: 500;
}

/* ==============================================================================
   CASE FILE EDIT MODAL
   ============================================================================== */

.case-file-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.modal-dialog {
  position: relative;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 8px;
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
}

.modal-dialog.modal-large {
  max-width: 1000px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-default);
}

.modal-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-close {
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: color 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  color: var(--crimson);
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.modal-textarea {
  width: 100%;
  min-height: 300px;
  padding: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: 4px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary);
  resize: vertical;
}

.modal-textarea:focus {
  outline: none;
  border-color: var(--crimson);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid var(--border-default);
}

.btn-primary {
  background: var(--crimson);
  border: none;
  padding: 10px 20px;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 500;
  color: white;
  cursor: pointer;
  transition: background 0.2s ease;
}

.btn-primary:hover {
  background: #c52341;
}

/* Evidence Preview Modal */
.evidence-preview-modal .modal-body {
  padding: 0;
}

.evidence-preview-modal iframe {
  width: 100%;
  height: 600px;
  border: none;
}
/* Success Toast */
.success-toast {
  position: fixed;
  bottom: var(--space-xl);
  right: var(--space-xl);
  background: #2e7d32;
  color: white;
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  font-size: var(--font-size-md);
  font-weight: 500;
  z-index: 10000;
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.3s ease;
}

.success-toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* =====================================================
   SUBMIT PANEL (Clean and Simple)
   ===================================================== */
.submit-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  background: var(--bg-deep);
  overflow-y: auto;
}

.submit-panel.hidden {
  display: none;
}

.submit-panel-container {
  max-width: 800px;
  margin: 0 auto;
  padding: var(--space-xl);
  width: 100%;
}

.submit-panel-header {
  margin-bottom: var(--space-xl);
  text-align: center;
}

.submit-panel-header h2 {
  font-size: var(--font-size-2xl);
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 var(--space-sm) 0;
}

.submit-panel-subtitle {
  font-size: var(--font-size-base);
  color: var(--text-secondary);
  margin: 0;
}

.submit-panel-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-xl);
}

.submit-section {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius);
  padding: var(--space-lg);
}

.submit-section h3 {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 var(--space-md) 0;
}

.submit-matter-info {
  font-size: var(--font-size-base);
  color: var(--text-primary);
}

.submit-conversation-summary {
  font-size: var(--font-size-base);
  color: var(--text-primary);
  line-height: 1.6;
}

.submit-actions {
  display: flex;
  justify-content: center;
  margin-top: var(--space-lg);
}

.submit-actions .btn-lg {
  padding: var(--space-md) var(--space-xl);
  font-size: var(--font-size-lg);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.submit-output {
  margin-top: var(--space-xl);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius);
  padding: var(--space-lg);
}

.submit-output.hidden {
  display: none;
}

.submit-output h3 {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 var(--space-md) 0;
}

.submit-output-content {
  font-size: var(--font-size-base);
  color: var(--text-primary);
  line-height: 1.6;
}

/* Mobile responsive */
@media (max-width: 768px) {
  .submit-panel-container {
    padding: var(--space-lg);
  }

  .submit-panel-header h2 {
    font-size: var(--font-size-xl);
  }

  .submit-actions .btn-lg {
    width: 100%;
    justify-content: center;
  }
}

/* ============================================================================
   RESPONSIVE DESIGN
   ============================================================================ */

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

  .upload-card {
    flex-direction: row;
  }

  .upload-icon {
    font-size: 28px;
  }

  .upload-open-btn {
    padding: 6px 12px;
    font-size: 12px;
  }
}


/* Uploads Tab Styles - Auto-generated */
/**
 * Apprentice Uploads Tab - CSS to Add
 *
 * These styles need to be added to styles-apprentice.css
 *
 * Add these at the end of the file or in the appropriate sections
 */

/* ============================================================================
   NESTED TABS STYLING
   ============================================================================ */

.nested-tabs-group {
  border-left: 3px solid var(--accent-red, #dc2626);
  margin-left: 8px;
  padding-left: 4px;
}

.nested-tabs-header {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted, #6b7280);
  padding: 8px 12px 4px;
  letter-spacing: 0.5px;
}

.nested-tab {
  margin-left: 8px;
  font-size: 13px;
}

/* ============================================================================
   STATUS INDICATOR (colored dots with animation)
   ============================================================================ */

.tab-status-indicator {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-left: 6px;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* ============================================================================
   CLASSIFICATION BADGE (document type badge)
   ============================================================================ */

.tab-classification-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--accent-red, #dc2626);
  color: white;
  margin-left: 6px;
  text-transform: uppercase;
}

/* ============================================================================
   UPLOADS LIST (grid of uploaded documents)
   ============================================================================ */

.uploads-list {
  padding: 20px;
}

.uploads-list h2 {
  margin-bottom: 20px;
  font-size: 24px;
  font-weight: 600;
}

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

/* ============================================================================
   UPLOAD CARD (individual file card)
   ============================================================================ */

.upload-card {
  background: var(--bg-surface, #ffffff);
  border: 1px solid var(--border-subtle, #e5e7eb);
  border-radius: 8px;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all 0.2s;
  cursor: pointer;
}

.upload-card:hover {
  border-color: var(--accent-red, #dc2626);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.upload-icon {
  font-size: 32px;
  flex-shrink: 0;
}

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

.upload-name {
  font-weight: 600;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.upload-meta {
  font-size: 12px;
  color: var(--text-muted, #6b7280);
  display: flex;
  gap: 12px;
  align-items: center;
}

.upload-category {
  font-weight: 500;
}

.upload-date {
  opacity: 0.7;
}

.upload-open-btn {
  background: var(--accent-red, #dc2626);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  transition: background 0.2s;
  flex-shrink: 0;
}

.upload-open-btn:hover {
  background: var(--accent-red-dark, #b91c1c);
}

.upload-open-btn:active {
  transform: scale(0.98);
}

/* ============================================================================
   EMPTY STATE (no uploads yet)
   ============================================================================ */

.uploads-empty-state {
  padding: 60px 20px;
  text-align: center;
  color: var(--text-muted, #6b7280);
}

.uploads-empty-state h3 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-primary, #111827);
}

.uploads-empty-state p {
  font-size: 14px;
}

/* ============================================================================
   ERROR STATE (failed to load uploads)
   ============================================================================ */

.uploads-error-state {
  padding: 60px 20px;
  text-align: center;
  color: var(--accent-red, #dc2626);
}

.uploads-error-state h3 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
}

.uploads-error-state p {
  font-size: 14px;
}

/* ============================================================================
   DARK MODE SUPPORT (if applicable)
   ============================================================================ */

@media (prefers-color-scheme: dark) {
  .upload-card {
    background: var(--bg-surface-dark, #1f2937);
    border-color: var(--border-subtle-dark, #374151);
  }

  .upload-card:hover {
    border-color: var(--accent-red, #dc2626);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  }

  .upload-name {
    color: var(--text-primary-dark, #f3f4f6);
  }

  .upload-meta {
    color: var(--text-muted-dark, #9ca3af);
  }

  .uploads-empty-state h3,
  .uploads-error-state h3 {
    color: var(--text-primary-dark, #f3f4f6);
  }
}

/* ============================================================================
   RESPONSIVE DESIGN
   ============================================================================ */

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

  .upload-card {
    flex-direction: row;
  }

  .upload-icon {
    font-size: 28px;
  }

  .upload-open-btn {
    padding: 6px 12px;
    font-size: 12px;
  }
}

/* ============================================================================
   UPLOADS SUBTABS STYLES
   ============================================================================ */

.uploads-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  text-align: center;
  color: var(--text-secondary);
}

.uploads-empty-state .empty-state-icon {
  width: 64px;
  height: 64px;
  margin-bottom: 1.5rem;
  color: var(--text-disabled);
}

.uploads-empty-state h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.uploads-empty-state p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 2rem;
}

.upload-trigger-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  background: var(--crimson);
  color: white;
  border: none;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.upload-trigger-btn:hover {
  background: var(--crimson-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
}

.upload-trigger-btn svg {
  width: 18px;
  height: 18px;
}

/* Document classification display */
.document-classification {
  padding: 2rem;
  max-width: 600px;
  margin: 0 auto;
}

.document-classification h3 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--border);
}

.classification-section {
  margin-bottom: 2rem;
}

.classification-section h4 {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
}

.classification-badge {
  display: inline-block;
  padding: 0.5rem 1rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.classification-confidence {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.suggested-tasks {
  list-style: none;
  padding: 0;
  margin: 0;
}

.suggested-tasks li {
  padding: 0.75rem 1rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
  transition: all 0.2s ease;
}

.suggested-tasks li:hover {
  background: var(--bg-elevated);
  border-color: var(--crimson);
  transform: translateX(4px);
}

/* Status badges on subtabs */
.secondary-tab[data-status="uploading"] .tab-icon {
  animation: pulse 1.5s ease-in-out infinite;
}

.secondary-tab[data-status="classifying"] .tab-icon {
  animation: pulse 1.5s ease-in-out infinite;
  color: var(--amber);
}

.secondary-tab[data-status="ready"] .tab-icon {
  color: var(--success);
}

.secondary-tab[data-status="error"] .tab-icon {
  color: var(--danger);
}

.secondary-tab .tab-name {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* ============================================================================
   DOCUMENT VIEWER (PDF & DOCX)
   ============================================================================ */

.document-viewer {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  overflow: hidden;
}

.viewer-content {
  flex: 1;
  overflow-y: auto;
  padding: 2rem;
  background: var(--bg-base);
}

.viewer-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  font-size: 1.1rem;
  color: var(--text-muted);
}

.viewer-error {
  padding: 3rem;
  text-align: center;
  color: var(--danger);
}

.viewer-error h3 {
  margin-bottom: 1rem;
  font-size: 1.25rem;
}

.viewer-toolbar {
  display: flex;
  justify-content: flex-end;
  padding: 1rem 1.5rem;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
}

.viewer-toolbar .btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* DOCX Viewer Styles */
.docx-viewer {
  max-width: 900px;
  margin: 0 auto;
  background: white;
  padding: 3rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  border-radius: 4px;
}

.viewer-header {
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--border);
}

.viewer-header h3 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.viewer-body {
  line-height: 1.6;
  color: #333;
}

.viewer-body p {
  margin-bottom: 1rem;
}

.viewer-body h1,
.viewer-body h2,
.viewer-body h3,
.viewer-body h4,
.viewer-body h5,
.viewer-body h6 {
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  font-weight: 600;
  color: #111;
}

.viewer-body ul,
.viewer-body ol {
  margin-bottom: 1rem;
  padding-left: 2rem;
}

.viewer-body li {
  margin-bottom: 0.5rem;
}

.viewer-body strong {
  font-weight: 600;
}

.viewer-body em {
  font-style: italic;
}

/* PDF Viewer Styles */
.pdf-viewer {
  max-width: 1200px;
  margin: 0 auto;
}

.pdf-viewer .viewer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  padding: 1rem;
  background: white;
  border-radius: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.pdf-page-count {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 500;
}

.pdf-pages {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  align-items: center;
}

.pdf-page-wrapper {
  background: white;
  padding: 1.5rem;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.pdf-page-canvas {
  max-width: 100%;
  height: auto;
  display: block;
  border: 1px solid var(--border-subtle);
}

.pdf-page-number {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  .docx-viewer,
  .pdf-viewer .viewer-header,
  .pdf-page-wrapper {
    background: var(--bg-elevated);
  }

  .viewer-body {
    color: var(--text-primary);
  }

  .viewer-body h1,
  .viewer-body h2,
  .viewer-body h3,
  .viewer-body h4,
  .viewer-body h5,
  .viewer-body h6 {
    color: var(--text-primary);
  }
}

/* Responsive Design */
@media (max-width: 768px) {
  .viewer-content {
    padding: 1rem;
  }

  .docx-viewer {
    padding: 1.5rem;
  }

  .pdf-page-wrapper {
    padding: 1rem;
  }
}
