/* ==========================================================================
   OmniLLM Arena — Design System & Stylesheet
   ========================================================================== */

:root {
  /* Color Palette - Core Dark (Default) */
  --bg-main: #0a0d14;
  --bg-subtle: #0f1420;
  --bg-card: #141b2d;
  --bg-card-hover: #182239;
  --bg-surface: #1e2942;
  --bg-surface-elevated: #263353;
  --bg-glass: rgba(16, 22, 36, 0.85);

  --border-subtle: rgba(255, 255, 255, 0.07);
  --border-medium: rgba(255, 255, 255, 0.14);
  --border-focus: rgba(99, 102, 241, 0.5);

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-inverse: #0f172a;

  /* Accent & Status Colors */
  --accent-primary: #6366f1;
  --accent-primary-hover: #4f46e5;
  --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #d946ef 100%);
  --accent-glow: rgba(99, 102, 241, 0.25);

  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #0ea5e9;

  /* Model Brand Accents */
  --brand-openai: #10a37f;
  --brand-claude: #d97706;
  --brand-gemini: #3b82f6;
  --brand-grok: #ec4899;
  --brand-deepseek: #0284c7;
  --brand-mistral: #f97316;
  --brand-meta: #8b5cf6;
  --brand-openrouter: #6366f1;

  /* Sizing & Radii */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px -2px rgba(0, 0, 0, 0.4), 0 2px 6px -1px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 12px 28px -4px rgba(0, 0, 0, 0.5), 0 4px 12px -2px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.2);

  /* Transitions */
  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Light Theme Overrides */
[data-theme="light"] {
  --bg-main: #f8fafc;
  --bg-subtle: #f1f5f9;
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;
  --bg-surface: #e2e8f0;
  --bg-surface-elevated: #cbd5e1;
  --bg-glass: rgba(255, 255, 255, 0.9);

  --border-subtle: rgba(0, 0, 0, 0.08);
  --border-medium: rgba(0, 0, 0, 0.15);
  --border-focus: rgba(99, 102, 241, 0.6);

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-inverse: #f8fafc;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 16px -2px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 12px 32px -4px rgba(0, 0, 0, 0.12);
}

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

html {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background-color: var(--bg-main);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  overflow-x: hidden;
  background-color: var(--bg-main);
  background-image: 
    radial-gradient(at 10% 10%, rgba(99, 102, 241, 0.04) 0px, transparent 50%),
    radial-gradient(at 90% 90%, rgba(139, 92, 246, 0.04) 0px, transparent 50%);
}

.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: 100%;
}

/* ==========================================================================
   Header Navigation
   ========================================================================== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  transition: all var(--transition-normal);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: var(--accent-gradient);
  color: #ffffff;
  font-size: 1.2rem;
  box-shadow: 0 2px 10px rgba(99, 102, 241, 0.35);
}

.logo-text h1 {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.logo-text h1 span {
  color: var(--accent-primary);
  font-weight: 700;
}

.badge-sub {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

/* Creator Neon Heartbeat Badge */
.creator-neon-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.42rem 1.25rem;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(99, 102, 241, 0.45);
  border-radius: var(--radius-full);
  box-shadow: 0 0 16px -2px rgba(99, 102, 241, 0.4);
  animation: neon-card-pulse 3.6s ease-in-out infinite;
  user-select: none;
}

.neon-heartbeat-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #38bdf8;
  box-shadow: 0 0 10px #38bdf8, 0 0 20px #6366f1;
  animation: slow-heartbeat 3.6s ease-in-out infinite;
}

.neon-name {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #ffffff;
  text-shadow: 
    0 0 6px rgba(56, 189, 248, 0.8),
    0 0 14px rgba(99, 102, 241, 0.6),
    0 0 24px rgba(217, 70, 239, 0.4);
  animation: neon-text-glow 3.6s ease-in-out infinite;
}

@keyframes slow-heartbeat {
  0% { transform: scale(1); opacity: 0.85; }
  14% { transform: scale(1.45); opacity: 1; box-shadow: 0 0 16px #38bdf8, 0 0 28px #d946ef; }
  28% { transform: scale(1.1); opacity: 0.9; }
  42% { transform: scale(1.5); opacity: 1; box-shadow: 0 0 20px #38bdf8, 0 0 32px #d946ef; }
  56% { transform: scale(1); opacity: 0.85; }
  100% { transform: scale(1); opacity: 0.85; }
}

@keyframes neon-card-pulse {
  0%, 100% {
    border-color: rgba(99, 102, 241, 0.45);
    box-shadow: 0 0 14px -2px rgba(99, 102, 241, 0.35);
  }
  28%, 42% {
    border-color: rgba(56, 189, 248, 0.8);
    box-shadow: 0 0 24px 2px rgba(56, 189, 248, 0.5), 0 0 35px rgba(217, 70, 239, 0.3);
  }
}

@keyframes neon-text-glow {
  0%, 100% {
    text-shadow: 
      0 0 6px rgba(56, 189, 248, 0.7),
      0 0 14px rgba(99, 102, 241, 0.5);
  }
  28%, 42% {
    text-shadow: 
      0 0 10px rgba(56, 189, 248, 1),
      0 0 20px rgba(99, 102, 241, 0.85),
      0 0 30px rgba(217, 70, 239, 0.65);
  }
}

/* Continue Generating Button */
.continue-btn-wrapper {
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px dashed rgba(245, 158, 11, 0.35);
  display: flex;
  justify-content: center;
}

.continue-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1.25rem;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.18), rgba(234, 88, 12, 0.18));
  border: 1px solid rgba(245, 158, 11, 0.5);
  border-radius: var(--radius-md);
  color: #fbbf24;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.25);
  transition: all var(--transition-fast);
}

.continue-btn:hover {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.3), rgba(234, 88, 12, 0.3));
  border-color: #f59e0b;
  color: #ffffff;
  transform: translateY(-1px);
  box-shadow: 0 0 18px rgba(245, 158, 11, 0.45);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.8rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.icon-btn:hover {
  background: var(--bg-surface-elevated);
  border-color: var(--border-medium);
  color: var(--text-primary);
}

.theme-toggle {
  width: 36px;
  height: 36px;
  padding: 0;
  justify-content: center;
  border-radius: 50%;
}

/* ==========================================================================
   Main Content Layout
   ========================================================================== */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 1.25rem 1.5rem;
  max-width: 1800px;
  margin: 0 auto;
  width: 100%;
  gap: 1.25rem;
}

/* ==========================================================================
   Control Station (Model Picker & Prompt Bar)
   ========================================================================== */
.control-station {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}

/* Models Panel */
.models-panel {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.models-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.models-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.section-label {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.selected-counter {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  background: rgba(99, 102, 241, 0.15);
  color: var(--accent-primary);
  border-radius: var(--radius-full);
  border: 1px solid rgba(99, 102, 241, 0.3);
}

/* Preset Pills */
.preset-pills {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.preset-pill {
  padding: 0.25rem 0.65rem;
  font-size: 0.78rem;
  font-weight: 500;
  border-radius: var(--radius-full);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.preset-pill:hover {
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
  border-color: var(--border-medium);
}

.preset-pill.active {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #ffffff;
}

.preset-pill.text-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
}
.preset-pill.text-btn:hover {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.1);
}

/* Models Grid */
.models-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 0.65rem;
}

.model-chip {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  user-select: none;
  transition: all var(--transition-fast);
  position: relative;
  overflow: hidden;
}

.model-chip:hover {
  background: var(--bg-surface-elevated);
  border-color: var(--border-medium);
  transform: translateY(-1px);
}

.model-chip.selected {
  background: var(--bg-surface-elevated);
  border-color: var(--chip-accent, var(--accent-primary));
  box-shadow: 0 0 12px -3px var(--chip-accent-glow, rgba(99, 102, 241, 0.3));
}

.model-chip::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: transparent;
  transition: background-color var(--transition-fast);
}

.model-chip.selected::before {
  background: var(--chip-accent, var(--accent-primary));
}

.model-icon-box {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--chip-accent, var(--text-primary));
  font-size: 1.05rem;
  flex-shrink: 0;
  border: 1px solid var(--border-subtle);
}

.model-info {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.model-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.model-meta {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.model-badge {
  font-size: 0.65rem;
  padding: 0.05rem 0.35rem;
  border-radius: 3px;
  background: var(--bg-card);
  color: var(--text-secondary);
}

.model-checkbox {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1.5px solid var(--border-medium);
  display: flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  font-size: 0.65rem;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.model-chip.selected .model-checkbox {
  background: var(--chip-accent, var(--accent-primary));
  border-color: var(--chip-accent, var(--accent-primary));
  color: #ffffff;
}

/* ==========================================================================
   Prompt Console
   ========================================================================== */
.prompt-console {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  border-top: 1px solid var(--border-subtle);
  padding-top: 1rem;
}

.console-subbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.templates-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.templates-row::-webkit-scrollbar {
  display: none;
}

.templates-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.3rem;
  white-space: nowrap;
}

.template-chip {
  padding: 0.25rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: var(--radius-full);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.template-chip:hover {
  background: var(--bg-surface-elevated);
  border-color: var(--accent-primary);
  color: var(--text-primary);
}

.system-prompt-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.system-prompt-toggle:hover {
  color: var(--text-primary);
  background: var(--bg-surface);
}

.toggle-arrow {
  font-size: 0.65rem;
  transition: transform var(--transition-fast);
}

.system-prompt-toggle.open .toggle-arrow {
  transform: rotate(180deg);
}

/* System Prompt Drawer */
.system-prompt-drawer {
  overflow: hidden;
  max-height: 200px;
  transition: max-height var(--transition-normal), opacity var(--transition-normal);
  opacity: 1;
}

.system-prompt-drawer.collapsed {
  max-height: 0;
  opacity: 0;
  pointer-events: none;
}

.system-prompt-inner {
  padding: 0.65rem 0.85rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.system-prompt-inner label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.system-prompt-inner input {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.65rem;
  font-size: 0.85rem;
  color: var(--text-primary);
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition-fast);
}

.system-prompt-inner input:focus {
  border-color: var(--accent-primary);
}

/* Prompt Input Box */
.prompt-input-wrapper {
  display: flex;
  flex-direction: column;
  background: var(--bg-subtle);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.prompt-input-wrapper:focus-within {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--border-focus);
}

#promptInput {
  width: 100%;
  min-height: 80px;
  max-height: 250px;
  padding: 0.85rem 1rem;
  background: transparent;
  border: none;
  outline: none;
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--text-primary);
  resize: vertical;
}

#promptInput::placeholder {
  color: var(--text-muted);
}

.input-actions-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.85rem;
  background: var(--bg-card);
  border-top: 1px solid var(--border-subtle);
  flex-wrap: wrap;
  gap: 0.5rem;
}

.input-stats {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.shortcut-tip kbd {
  display: inline-block;
  padding: 0.1rem 0.35rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  color: var(--text-secondary);
}

.input-buttons {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.5rem 1.1rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition-fast);
}

.action-btn.primary {
  background: var(--accent-gradient);
  color: #ffffff;
  box-shadow: 0 2px 10px rgba(99, 102, 241, 0.3);
}

.action-btn.primary:hover {
  filter: brightness(1.1);
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
  transform: translateY(-1px);
}

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

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

.action-btn.stop-btn {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.3);
  color: var(--danger);
}

.action-btn.stop-btn:hover {
  background: rgba(239, 68, 68, 0.25);
}

.action-btn.full-width {
  width: 100%;
}

/* ==========================================================================
   Results Toolbar
   ========================================================================== */
.results-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.toolbar-left {
  display: flex;
  align-items: center;
  min-width: 0;
  flex: 1;
}

.active-query-summary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
  overflow: hidden;
}

.active-query-summary i {
  color: var(--accent-primary);
  flex-shrink: 0;
}

.query-preview {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.tool-btn:hover:not(:disabled) {
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
  border-color: var(--border-medium);
}

.tool-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.tool-btn.active {
  background: rgba(99, 102, 241, 0.15);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.tool-btn.highlight {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(217, 70, 239, 0.15));
  border-color: rgba(99, 102, 241, 0.4);
  color: var(--text-primary);
}

.tool-btn.highlight:hover:not(:disabled) {
  border-color: var(--accent-primary);
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.3);
}

/* Layout Switch Group */
.layout-switch-group {
  display: flex;
  align-items: center;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 2px;
}

.layout-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 26px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 4px;
  font-size: 0.75rem;
  transition: all var(--transition-fast);
}

.layout-btn:hover {
  color: var(--text-primary);
}

.layout-btn.active {
  background: var(--bg-card);
  color: var(--accent-primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* Export Dropdown */
.export-dropdown-wrap {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 0.4rem;
  min-width: 180px;
  display: none;
  flex-direction: column;
  gap: 0.2rem;
  z-index: 120;
}

.dropdown-menu.show {
  display: flex;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  transition: all var(--transition-fast);
}

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

/* ==========================================================================
   Comparison Grid & Model Response Cards
   ========================================================================== */
.comparison-canvas {
  flex: 1;
  position: relative;
  min-height: 400px;
}

.responses-grid {
  display: grid;
  gap: 1.25rem;
  width: 100%;
}

.responses-grid.layout-auto {
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
}

.responses-grid.layout-1 {
  grid-template-columns: 1fr;
}

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

.responses-grid.layout-3 {
  grid-template-columns: repeat(3, 1fr);
}

@media (max-width: 1100px) {
  .responses-grid.layout-3 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .responses-grid.layout-2,
  .responses-grid.layout-3,
  .responses-grid.layout-auto {
    grid-template-columns: 1fr;
  }
}

/* Response Card */
.response-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  position: relative;
}

.response-card:hover {
  border-color: var(--border-medium);
  box-shadow: var(--shadow-md);
}

.response-card.winner {
  border-color: #eab308;
  box-shadow: 0 0 20px rgba(234, 179, 8, 0.2);
}

.response-card.winner::before {
  content: '👑 Winner';
  position: absolute;
  top: -1px;
  right: 20px;
  background: #eab308;
  color: #000000;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 0.15rem 0.5rem;
  border-bottom-left-radius: 4px;
  border-bottom-right-radius: 4px;
  z-index: 10;
  text-transform: uppercase;
}

/* Card Header */
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.1rem;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  position: relative;
}

.card-header::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--card-brand-color, var(--accent-primary));
  opacity: 0.8;
}

.card-model-meta {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.card-model-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--card-brand-color, var(--text-primary));
  font-size: 0.95rem;
}

.card-model-title {
  display: flex;
  flex-direction: column;
}

.card-model-name {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
}

.card-model-sub {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.card-header-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.card-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.card-action-btn:hover {
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
  border-color: var(--border-medium);
}

.card-action-btn.win-btn.active {
  background: #eab308;
  color: #000000;
  border-color: #eab308;
}

/* Card Metrics Bar */
.card-metrics {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 1.1rem;
  background: rgba(0, 0, 0, 0.15);
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.72rem;
  color: var(--text-muted);
}

.metrics-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-weight: 600;
}

.status-badge.streaming {
  color: var(--accent-primary);
}

.status-badge.complete {
  color: var(--success);
}

.status-badge.error {
  color: var(--danger);
}

.pulse-indicator {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse-dot 1.2s infinite ease-in-out;
}

.metric-item {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.metric-item strong {
  color: var(--text-secondary);
  font-family: 'JetBrains Mono', monospace;
}

/* Card Body & Content Stream */
.card-body {
  padding: 1.25rem;
  min-height: 250px;
  max-height: 600px;
  overflow-y: auto;
  font-size: 0.92rem;
  line-height: 1.65;
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

/* Thinking Trace Accordion (For DeepSeek-R1 / Reasoning Models) */
.thinking-accordion {
  border: 1px solid rgba(99, 102, 241, 0.25);
  background: rgba(99, 102, 241, 0.05);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 0.75rem;
}

.thinking-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.85rem;
  background: rgba(99, 102, 241, 0.1);
  cursor: pointer;
  user-select: none;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent-primary);
}

.thinking-title {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.thinking-content {
  padding: 0.75rem 0.85rem;
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--text-secondary);
  font-style: italic;
  border-top: 1px solid rgba(99, 102, 241, 0.15);
  background: rgba(0, 0, 0, 0.1);
  white-space: pre-wrap;
  display: none;
}

.thinking-accordion.expanded .thinking-content {
  display: block;
}

.thinking-accordion.expanded .thinking-header i.fa-chevron-right {
  transform: rotate(90deg);
}

/* Markdown Rendering inside Response Card */
.markdown-body {
  word-break: break-word;
}

.markdown-body p {
  margin-bottom: 0.85rem;
}

.markdown-body p:last-child {
  margin-bottom: 0;
}

.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4 {
  margin-top: 1rem;
  margin-bottom: 0.5rem;
  font-weight: 700;
  color: var(--text-primary);
}

.markdown-body h1 { font-size: 1.3rem; }
.markdown-body h2 { font-size: 1.15rem; }
.markdown-body h3 { font-size: 1.02rem; }

.markdown-body ul, .markdown-body ol {
  margin-bottom: 0.85rem;
  padding-left: 1.4rem;
}

.markdown-body li {
  margin-bottom: 0.35rem;
}

.markdown-body blockquote {
  padding: 0.5rem 0.85rem;
  border-left: 3px solid var(--accent-primary);
  background: var(--bg-surface);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin-bottom: 0.85rem;
  color: var(--text-secondary);
  font-style: italic;
}

/* Code Snippets & Syntax Block */
.code-block-wrapper {
  margin: 0.85rem 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #090d16;
  border: 1px solid var(--border-medium);
}

.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.35rem 0.75rem;
  background: #111827;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
}

.copy-code-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 0.7rem;
  cursor: pointer;
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  transition: all var(--transition-fast);
}

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

.markdown-body pre {
  padding: 0.85rem;
  overflow-x: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.84rem;
  line-height: 1.5;
  color: #e2e8f0;
}

.markdown-body code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.84rem;
  padding: 0.15rem 0.35rem;
  background: var(--bg-surface);
  border-radius: 4px;
  color: #e0e7ff;
}

.markdown-body pre code {
  padding: 0;
  background: transparent;
}

/* Markdown Tables */
.table-wrapper {
  overflow-x: auto;
  margin: 0.85rem 0;
}

.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.markdown-body th, .markdown-body td {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border-medium);
  text-align: left;
}

.markdown-body th {
  background: var(--bg-surface);
  font-weight: 600;
  color: var(--text-primary);
}

.markdown-body tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.02);
}

/* Streaming Typing Cursor */
.streaming-cursor {
  display: inline-block;
  width: 7px;
  height: 15px;
  background: var(--accent-primary);
  margin-left: 2px;
  vertical-align: middle;
  animation: blink-cursor 0.8s infinite;
}

/* ==========================================================================
   Empty State
   ========================================================================== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 4rem 1.5rem;
  background: var(--bg-card);
  border: 1px dashed var(--border-medium);
  border-radius: var(--radius-xl);
  max-width: 900px;
  margin: 2rem auto;
}

.empty-icon-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: var(--radius-lg);
  background: rgba(99, 102, 241, 0.1);
  color: var(--accent-primary);
  font-size: 2rem;
  margin-bottom: 1.25rem;
}

.empty-state h3 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.empty-state p {
  font-size: 0.95rem;
  color: var(--text-secondary);
  max-width: 540px;
  margin-bottom: 2rem;
}

.empty-features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  width: 100%;
  text-align: left;
}

.feature-item {
  padding: 1rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.feature-item i {
  color: var(--accent-primary);
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
}

.feature-item h4 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.feature-item span {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ==========================================================================
   Modals & Drawers
   ========================================================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  width: 100%;
  max-width: 580px;
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  transform: translateY(12px);
  transition: transform var(--transition-normal);
}

.modal-overlay.open .modal-card {
  transform: translateY(0);
}

.modal-card.wide {
  max-width: 820px;
}

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

.modal-title {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--text-primary);
}

.modal-title i {
  color: var(--accent-primary);
}

.modal-title h2 {
  font-size: 1.1rem;
  font-weight: 700;
}

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

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

.modal-body {
  padding: 1.25rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 0.85rem 1.25rem;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
}

/* Radio Engine Card */
.engine-mode-select {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

.radio-card {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.radio-card:hover {
  border-color: var(--border-medium);
}

.radio-card.active {
  border-color: var(--accent-primary);
  background: rgba(99, 102, 241, 0.08);
}

.radio-card input {
  margin-top: 0.25rem;
  accent-color: var(--accent-primary);
}

.radio-card-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.2rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.radio-card-title i {
  color: var(--accent-primary);
}

.radio-card-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.openrouter-spotlight {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 1rem;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.12), rgba(139, 92, 246, 0.08));
  border: 1px solid rgba(99, 102, 241, 0.35);
  border-radius: var(--radius-md);
}

.spotlight-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.spotlight-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.badge-recommended {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-full);
  background: rgba(99, 102, 241, 0.2);
  color: var(--accent-primary);
  border: 1px solid rgba(99, 102, 241, 0.4);
}

.test-key-btn {
  padding: 0.3rem 0.65rem;
  font-size: 0.75rem;
}

.key-status-msg {
  font-size: 0.78rem;
  font-weight: 500;
  min-height: 18px;
  display: none;
}

.key-status-msg.show {
  display: block;
}

.key-status-msg.success {
  color: var(--success);
}

.key-status-msg.error {
  color: var(--danger);
}

.key-status-msg.loading {
  color: var(--accent-primary);
}

.input-grid-2col {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

@media (max-width: 600px) {
  .input-grid-2col {
    grid-template-columns: 1fr;
  }
}

.key-input-wrap input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  padding: 0.5rem 0.25rem;
  font-size: 0.85rem;
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
}

.toggle-vis-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0.25rem;
}

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

/* Sliders */
.param-slider-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.85rem;
}

.slider-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.slider-header strong {
  color: var(--text-primary);
}

.slider-hint {
  font-size: 0.7rem;
  color: var(--text-muted);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent-primary);
  cursor: pointer;
}

/* Consensus Modal Formatting */
.consensus-section {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding: 1rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.consensus-section h4 {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}

.consensus-section.agreement h4 i { color: var(--success); }
.consensus-section.divergence h4 i { color: var(--warning); }
.consensus-section.unique h4 i { color: var(--info); }
.consensus-section.recommendation h4 i { color: var(--accent-primary); }

.consensus-list {
  padding-left: 1.2rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.consensus-list li {
  margin-bottom: 0.4rem;
}

/* History Drawer */
.history-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 360px;
  background: var(--bg-card);
  border-left: 1px solid var(--border-medium);
  box-shadow: var(--shadow-lg);
  z-index: 250;
  transform: translateX(100%);
  transition: transform var(--transition-normal);
  display: flex;
  flex-direction: column;
}

.history-drawer.open {
  transform: translateX(0);
}

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

.drawer-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
  color: var(--text-primary);
}

.drawer-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
}

.drawer-body {
  flex: 1;
  padding: 0.85rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.history-item {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.75rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.history-item:hover {
  background: var(--bg-surface-elevated);
  border-color: var(--accent-primary);
}

.history-prompt {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.history-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.drawer-footer {
  padding: 0.85rem;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface);
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 300;
  pointer-events: none;
}

.toast {
  padding: 0.65rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  animation: slide-in 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: auto;
}

.toast.success i { color: var(--success); }
.toast.info i { color: var(--info); }
.toast.error i { color: var(--danger); }

/* ==========================================================================
   Futuristic Security Portal Overlay
   ========================================================================== */
.security-portal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 8, 16, 0.88);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  overflow: hidden;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.6s ease;
}

.security-portal-overlay.unlocked {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* Background Cyber Grid */
.portal-backdrop-grid {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: 
    linear-gradient(rgba(99, 102, 241, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(99, 102, 241, 0.07) 1px, transparent 1px);
  background-size: 40px 40px;
  perspective: 600px;
  transform: scale(1.1);
  pointer-events: none;
  animation: grid-drift 20s linear infinite;
}

/* Concentric Cyber Rings */
.portal-cyber-ring {
  position: absolute;
  border-radius: 50%;
  border: 1px dashed rgba(99, 102, 241, 0.2);
  pointer-events: none;
}

.portal-cyber-ring.ring-1 {
  width: 600px;
  height: 600px;
  border-top-color: rgba(99, 102, 241, 0.5);
  border-bottom-color: rgba(217, 70, 239, 0.5);
  animation: rotate-ring 35s linear infinite;
}

.portal-cyber-ring.ring-2 {
  width: 850px;
  height: 850px;
  border-left-color: rgba(59, 130, 246, 0.4);
  border-right-color: rgba(16, 185, 129, 0.4);
  animation: rotate-ring-rev 45s linear infinite;
}

.portal-cyber-ring.ring-3 {
  width: 1100px;
  height: 1100px;
  border: 1px solid rgba(255, 255, 255, 0.03);
}

/* Glassmorphic Portal Card */
.portal-card {
  position: relative;
  width: 90%;
  max-width: 520px;
  padding: 2.25rem 2rem;
  background: rgba(13, 18, 32, 0.75);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(99, 102, 241, 0.35);
  border-radius: var(--radius-xl);
  box-shadow: 0 0 50px -10px rgba(99, 102, 241, 0.3), 0 20px 40px rgba(0, 0, 0, 0.7);
  overflow: hidden;
  z-index: 10;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.3s ease;
}

.portal-card.shake {
  animation: portal-shake 0.5s ease;
  border-color: var(--danger);
  box-shadow: 0 0 40px rgba(239, 68, 68, 0.4);
}

.portal-card.grant {
  border-color: var(--success);
  box-shadow: 0 0 50px rgba(16, 185, 129, 0.5);
  transform: scale(1.03);
}

/* Scanning Laser Bar */
.portal-scanner-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, #6366f1, #d946ef, #6366f1, transparent);
  box-shadow: 0 0 12px #6366f1;
  animation: laser-sweep 2.8s ease-in-out infinite;
}

/* Header */
.portal-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: 1.75rem;
}

.portal-icon-container {
  position: relative;
  width: 68px;
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(99, 102, 241, 0.12);
  border: 1.5px solid rgba(99, 102, 241, 0.4);
  margin-bottom: 1.1rem;
}

.portal-icon-pulse {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 1px solid var(--accent-primary);
  animation: pulse-ring 2.2s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
}

.portal-lock-icon {
  font-size: 1.8rem;
  color: var(--accent-primary);
  transition: transform 0.3s ease, color 0.3s ease;
}

.portal-card.grant .portal-lock-icon {
  color: var(--success);
  transform: scale(1.15);
}

.portal-sys-tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--accent-primary);
  margin-bottom: 0.35rem;
  display: block;
}

.portal-title {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin-bottom: 0.35rem;
}

.portal-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  max-width: 360px;
  line-height: 1.45;
}

/* Cyber Form */
.portal-form {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

/* Large Input Field */
.portal-input-container {
  display: flex;
  align-items: center;
  background: rgba(8, 12, 22, 0.85);
  border: 1.5px solid rgba(99, 102, 241, 0.35);
  border-radius: var(--radius-lg);
  padding: 0.4rem 0.85rem;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.5);
  transition: all var(--transition-fast);
}

.portal-input-container:focus-within {
  border-color: var(--accent-primary);
  box-shadow: 0 0 20px rgba(99, 102, 241, 0.35), inset 0 2px 6px rgba(0, 0, 0, 0.5);
}

.portal-input-prefix {
  font-size: 1.3rem;
  color: var(--accent-primary);
  margin-right: 0.75rem;
  opacity: 0.8;
}

.portal-input-large {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: #ffffff;
  padding: 0.65rem 0;
  text-align: center;
}

.portal-input-large::placeholder {
  font-size: 1.05rem;
  letter-spacing: 0.1em;
  color: rgba(148, 163, 184, 0.35);
  font-weight: 500;
}

.portal-vis-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.5rem;
  transition: color var(--transition-fast);
}

.portal-vis-btn:hover {
  color: var(--text-primary);
}

/* Feedback Status Line */
.portal-feedback {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  min-height: 20px;
}

.portal-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-primary);
  box-shadow: 0 0 6px var(--accent-primary);
}

.portal-feedback.error {
  color: var(--danger);
}
.portal-feedback.error .portal-status-dot {
  background: var(--danger);
  box-shadow: 0 0 8px var(--danger);
}

.portal-feedback.success {
  color: var(--success);
}
.portal-feedback.success .portal-status-dot {
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
}

/* Submit Action Button */
.portal-submit-btn {
  position: relative;
  width: 100%;
  padding: 0.85rem 1.5rem;
  background: var(--accent-gradient);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.portal-submit-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(99, 102, 241, 0.55);
}

.portal-submit-btn:active {
  transform: translateY(0);
}

.btn-content {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #ffffff;
}

.portal-hint {
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  margin-top: 0.2rem;
}

.hint-code {
  font-family: 'JetBrains Mono', monospace;
  background: rgba(255, 255, 255, 0.08);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  color: var(--accent-primary);
  font-weight: 700;
}

/* Keyframe Animations */
@keyframes grid-drift {
  0% { transform: translateY(0) scale(1.1); }
  100% { transform: translateY(40px) scale(1.1); }
}

@keyframes rotate-ring {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes rotate-ring-rev {
  0% { transform: rotate(360deg); }
  100% { transform: rotate(0deg); }
}

@keyframes laser-sweep {
  0%, 100% { opacity: 0.4; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(100%); }
}

@keyframes pulse-ring {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.35); opacity: 0; }
  100% { transform: scale(0.95); opacity: 0; }
}

@keyframes portal-shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

/* Animations */
@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

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

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

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

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