/* Reset and base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: #ffffff;
  color: #1e293b;
  line-height: 1.6;
  min-height: 100vh;
}

/* Container and layout */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
  background: #ffffff;
}

/* Mobile-first responsive design */
@media (min-width: 768px) {
  .container {
    padding: 2rem;
  }
}

/* Grid system for responsive layout */
.grid {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: 1fr;
}

@media (min-width: 768px) {
  .grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Card components */
.card {
  background: #ffffff;
  border-radius: 16px;
  padding: 1.5rem;
  border: 1px solid #e2e8f0;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  transition: all 0.3s ease;
}

.card:hover {
  transform: translateY(-2px);
  border-color: rgba(59, 130, 246, 0.3);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

/* Form controls */
input, textarea {
  width: 100%;
  padding: 0.875rem 1rem;
  margin-top: 0.5rem;
  background: #ffffff;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  color: #1e293b;
  font-size: 1rem;
  transition: all 0.3s ease;
  resize: vertical;
}

input:focus, textarea:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
  background: #ffffff;
}

input::placeholder, textarea::placeholder {
  color: #94a3b8;
}

/* Button styles */
button {
  padding: 0.875rem 1.5rem;
  margin-top: 1rem;
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  color: white;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  min-width: 120px;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.2);
}

button:hover {
  background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.3);
}

button:active {
  transform: translateY(0);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Touch-friendly targets for mobile */
@media (max-width: 767px) {
  button {
    min-height: 48px;
    padding: 1rem 1.5rem;
  }
  
  input, textarea {
    min-height: 48px;
    font-size: 16px; /* Prevents zoom on iOS */
  }
}
/* Output sections */
#output, #toneOutput, #manifestoOutput {
  margin-top: 1rem;
  background: #ffffff;
  padding: 1.5rem;
  white-space: pre-wrap;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  border-left: 4px solid #3b82f6;
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 0.9rem;
  overflow-x: auto;
  color: #374151;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* Smooth transitions */
body.transition {
  transition: background 1s ease;
}

/* Header styling */
header {
  margin-bottom: 3rem;
  padding: 2rem 1rem;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 20px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

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

.header-right {
  flex-shrink: 0;
  min-width: 200px;
}

.logo {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(59, 130, 246, 0.3);
  box-shadow: 0 4px 20px rgba(59, 130, 246, 0.2);
  flex-shrink: 0;
  transition: all 0.3s ease;
}

.logo:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 25px rgba(59, 130, 246, 0.3);
}

.title-section {
  flex: 1;
  text-align: left;
}

header h1 {
  font-size: clamp(0.75rem, 2vw, 1.25rem);
  font-weight: 700;
  background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.75rem;
}

header p {
  font-size: clamp(0.7rem, 1.6vw, 0.8rem);
  color: #475569;
  max-width: 600px;
  margin: 0;
  line-height: 1.6;
}

/* Section headings */
h2 {
  font-size: clamp(1.5rem, 3vw, 2rem);
  color: #1e293b;
  margin: 2rem 0 1rem 0;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid rgba(59, 130, 246, 0.3);
  position: relative;
}

h2::before {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 50px;
  height: 2px;
  background: linear-gradient(90deg, #3b82f6, #8b5cf6);
}

/* Canvas styling */
#graphCanvas {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  margin-top: 1rem;
  width: 100%;
  height: auto;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* Tone prompt styling */
#tonePrompt {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-left: 4px solid #8b5cf6;
  padding: 1.5rem;
  margin-top: 1rem;
  font-style: italic;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  color: #475569;
}

/* User status */
#userStatus {
  background: #f8fafc;
  padding: 1rem;
  margin: 1.5rem 0;
  text-align: center;
  border-radius: 12px;
  font-weight: 600;
  border: 1px solid #e2e8f0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* History items */
.history-item {
  background: #ffffff;
  padding: 1.25rem;
  margin: 1rem 0;
  border-left: 4px solid #3b82f6;
  border-radius: 12px;
  transition: all 0.3s ease;
  border: 1px solid #e2e8f0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.history-item:hover {
  background: #f8fafc;
  transform: translateX(4px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.history-item strong {
  color: #3b82f6;
  font-weight: 600;
}

.history-item small {
  display: block;
  margin-top: 0.75rem;
  opacity: 0.7;
  font-size: 0.875rem;
  color: #64748b;
}

/* History sections */
#equationHistory, #toneHistory, #manifestoHistory, #spectralHistory {
  margin-bottom: 2rem;
}

#equationHistory h4, #toneHistory h4, #manifestoHistory h4, #spectralHistory h4 {
  color: #3b82f6;
  margin-bottom: 1rem;
  font-size: 1.25rem;
  font-weight: 600;
}

/* Spectral button styling */
.spectral-btn {
  background: linear-gradient(135deg, #8b5cf6 0%, #3b82f6 100%);
  color: white;
  border: none;
  padding: 1.25rem 2rem;
  font-size: 1.1rem;
  border-radius: 16px;
  cursor: pointer;
  margin: 1.5rem 0;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  transition: all 0.4s ease;
  box-shadow: 0 8px 25px rgba(139, 92, 246, 0.3);
  position: relative;
  overflow: hidden;
  min-width: 280px;
}

.spectral-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.6s ease;
}

.spectral-btn:hover::before {
  left: 100%;
}

.spectral-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 35px rgba(139, 92, 246, 0.4);
  background: linear-gradient(135deg, #7c3aed 0%, #2563eb 100%);
}

/* Spectral container */
.spectral-container {
  margin-top: 2rem;
  border: 2px solid rgba(139, 92, 246, 0.3);
  border-radius: 20px;
  overflow: hidden;
  background: #ffffff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.spectral-note {
  padding: 1.5rem;
  background: #f8fafc;
  margin: 0;
  font-style: italic;
  opacity: 0.9;
  border-top: 1px solid #e2e8f0;
  color: #64748b;
}

#spectralFrame {
  margin-top: 2rem;
}

#spectralFrame iframe {
  border-radius: 20px 20px 0 0;
  width: 100%;
  height: 80vh;
  border: none;
}

/* Responsive utilities */
.mobile-only {
  display: block;
}

.desktop-only {
  display: none;
}

@media (min-width: 768px) {
  .mobile-only {
    display: none;
  }
  
  .desktop-only {
    display: block;
  }
}

/* Loading states */
.loading {
  opacity: 0.6;
  pointer-events: none;
  position: relative;
}

.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid #3b82f6;
  border-top: 2px solid transparent;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Graph Controls */
.graph-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  margin-bottom: 15px;
  padding: 10px;
  background: #f8f9fa;
  border-radius: 8px;
  border: 1px solid #e9ecef;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.control-group label {
  font-weight: 500;
  color: #495057;
  font-size: 14px;
}

.control-group select {
  padding: 6px 10px;
  border: 1px solid #ced4da;
  border-radius: 4px;
  background: white;
  font-size: 14px;
}

.control-group input[type="checkbox"] {
  margin-right: 5px;
}

.graph-container {
  position: relative;
  margin: 15px 0;
  background: white;
  border-radius: 8px;
  padding: 10px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.graph-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 15px;
}

.export-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.analysis-buttons {
  display: flex;
  gap: 10px;
  margin: 1rem 0;
  flex-wrap: wrap;
}

.export-btn {
  background: linear-gradient(135deg, #059669 0%, #22c55e 100%);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.3s ease;
  font-weight: 500;
}

.export-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.3);
  background: linear-gradient(135deg, #047857 0%, #16a34a 100%);
}

.export-btn:disabled {
  background: #9ca3af;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Export Modal Styles */
.export-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10000;
}

.export-modal-content {
  background: white;
  border-radius: 16px;
  width: 90%;
  max-width: 500px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

.export-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
  border-bottom: 1px solid #e2e8f0;
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border-radius: 16px 16px 0 0;
}

.export-modal-header h3 {
  margin: 0;
  color: #1e293b;
  font-size: 1.25rem;
  font-weight: 600;
}

.export-modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #64748b;
  padding: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.export-modal-close:hover {
  background: #f1f5f9;
  color: #1e293b;
}

.export-modal-body {
  padding: 1.5rem;
}

.export-options {
  display: grid;
  gap: 1rem;
}

.export-option {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  background: white;
}

.export-option:hover {
  border-color: #3b82f6;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
}

.export-icon {
  font-size: 2rem;
  width: 48px;
  text-align: center;
}

.export-details h4 {
  margin: 0 0 0.25rem 0;
  color: #1e293b;
  font-size: 1rem;
  font-weight: 600;
}

.export-details p {
  margin: 0;
  color: #64748b;
  font-size: 0.875rem;
  line-height: 1.4;
}

@media (max-width: 640px) {
  .export-modal-content {
    width: 95%;
    margin: 1rem;
  }
  
  .export-option {
    flex-direction: column;
    text-align: center;
    gap: 0.5rem;
  }
  
  .export-icon {
    width: auto;
  }
}

/* Voice Input and File Upload Styles */
.input-controls {
  margin-bottom: 1rem;
}

.input-area {
  position: relative;
}

.input-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}

.voice-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  background: white;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 0.9rem;
}

.voice-toggle:hover {
  border-color: #3b82f6;
  background: #f8fafc;
}

.voice-toggle.active {
  border-color: #ef4444;
  background: #fef2f2;
  color: #dc2626;
}

.voice-toggle.active .voice-icon {
  animation: pulse 1.5s infinite;
}

.voice-toggle.active .voice-status::after {
  content: " • Recording";
  font-weight: bold;
}

.file-upload-btn {
  padding: 0.5rem 1rem;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  background: white;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 0.9rem;
}

.file-upload-btn:hover {
  border-color: #10b981;
  background: #f0fdf4;
  color: #059669;
}

.file-display {
  margin: 1rem 0;
  padding: 0.75rem;
  background: #f8fafc;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  display: none;
}

.file-display.has-files {
  display: block;
}

.file-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem;
  margin: 0.25rem 0;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
}

.file-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.file-icon {
  font-size: 1.2rem;
}

.file-details {
  font-size: 0.9rem;
}

.file-name {
  font-weight: 500;
  color: #1e293b;
}

.file-size {
  color: #64748b;
  font-size: 0.8rem;
}

.file-remove {
  background: #fee2e2;
  color: #dc2626;
  border: none;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8rem;
}

.file-remove:hover {
  background: #fecaca;
}

/* Chat Interface Styles */
.chat-container {
  max-height: 500px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  overflow: hidden;
  background: white;
}

.chat-messages {
  height: 350px;
  overflow-y: auto;
  padding: 1rem;
  background: #fafafa;
}

.chat-message {
  margin-bottom: 1rem;
  display: flex;
}

.user-message {
  justify-content: flex-end;
}

.assistant-message {
  justify-content: flex-start;
}

.message-content {
  max-width: 80%;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.4;
}

.user-message .message-content {
  background: #3b82f6;
  color: white;
  border-bottom-right-radius: 4px;
}

.assistant-message .message-content {
  background: white;
  border: 1px solid #e2e8f0;
  border-bottom-left-radius: 4px;
}

.message-content img {
  max-width: 100%;
  border-radius: 8px;
  margin: 0.5rem 0;
}

.message-content ul, .message-content ol {
  margin: 0.5rem 0;
  padding-left: 1.25rem;
}

.message-content li {
  margin: 0.25rem 0;
}

.chat-input-area {
  border-top: 1px solid #e2e8f0;
  padding: 1rem;
  background: white;
}

.chat-input-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.chat-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.send-btn {
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.3s ease;
}

.send-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.send-btn:disabled {
  background: #9ca3af;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Responsive adjustments */
@media (max-width: 640px) {
  .input-actions, .chat-actions {
    justify-content: space-between;
  }
  
  .chat-messages {
    height: 250px;
  }
  
  .message-content {
    max-width: 90%;
  }
}

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

.primary-btn {
  background: #007bff;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s ease;
}

.primary-btn:hover {
  background: #0056b3;
  transform: translateY(-1px);
}

.secondary-btn {
  background: #6c757d;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s ease;
}

.secondary-btn:hover {
  background: #545b62;
  transform: translateY(-1px);
}

.graph-stats {
  margin-top: 10px;
  padding: 8px 12px;
  background: #e9ecef;
  border-radius: 4px;
  font-size: 13px;
  color: #495057;
  min-height: 20px;
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Focus indicators for keyboard navigation */
button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .card {
    border: 2px solid #ffffff;
  }
  
  button {
    border: 2px solid #ffffff;
  }
}

/* Mobile details/summary styling */
details {
  margin: 1rem 0;
}

details summary {
  padding: 1rem;
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.3s ease;
}

details summary:hover {
  background: rgba(59, 130, 246, 0.2);
}

details[open] summary {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  border-bottom: none;
}

details[open] > *:not(summary) {
  padding: 1rem;
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-top: none;
  border-radius: 0 0 8px 8px;
  background: #ffffff;
}

/* Canvas responsive adjustments */
canvas {
  max-width: 100%;
  height: auto;
}

/* Code elements */
code {
  background: rgba(59, 130, 246, 0.1);
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 0.9em;
}

/* Improved scrollbars for webkit browsers */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.5);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: rgba(59, 130, 246, 0.5);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(59, 130, 246, 0.7);
}

/* Mobile-specific optimizations */
@media (max-width: 767px) {
  .container {
    padding: 0.5rem;
  }
  
  header {
    margin-bottom: 2rem;
    padding: 1.5rem 1rem;
  }
  
  .card {
    padding: 1rem;
  }
  
  h2 {
    font-size: 1.5rem;
    margin: 1rem 0 0.5rem 0;
  }
  
  .spectral-btn {
    min-width: 100%;
    padding: 1rem;
    font-size: 1rem;
  }
  
  #spectralFrame iframe {
    height: 60vh;
  }
  
  textarea {
    min-height: 80px;
  }
}

/* Tablet optimizations */
@media (min-width: 768px) and (max-width: 1023px) {
  .grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .card:nth-child(5) {
    grid-column: 1 / -1;
  }
  
  .card:nth-child(6) {
    grid-column: 1 / -1;
  }
}

/* Large desktop optimizations */
@media (min-width: 1400px) {
  .container {
    max-width: 1400px;
  }
  
  .grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Notification system */
.notification {
  max-width: 300px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(10px);
}

/* Enhanced focus states */
.card.focused {
  border-color: rgba(59, 130, 246, 0.5);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}

/* Loading animations */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.loading {
  animation: pulse 1.5s ease-in-out infinite;
}

/* Performance optimizations */
.card, button, input, textarea {
  will-change: transform;
}

/* iOS specific fixes */
@supports (-webkit-touch-callout: none) {
  input, textarea {
    -webkit-appearance: none;
    border-radius: 12px;
  }
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
  .card:hover {
    transform: none;
  }
  
  button:hover {
    transform: none;
  }
  
  .history-item:hover {
    transform: none;
  }
}

/* Documentation accordion styling */
.documentation-card {
  margin-bottom: 2rem;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.main-docs summary.docs-header {
  padding: 1.5rem;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.1) 0%, rgba(139, 92, 246, 0.1) 100%);
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  cursor: pointer;
  font-weight: 700;
  font-size: 1.2rem;
  color: #1e293b;
  transition: all 0.3s ease;
  text-align: center;
}

.main-docs summary.docs-header:hover {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.15) 0%, rgba(139, 92, 246, 0.15) 100%);
  transform: translateY(-1px);
}

.main-docs[open] summary.docs-header {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  border-bottom: 1px solid rgba(59, 130, 246, 0.3);
}

.docs-content {
  padding: 2rem;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-top: none;
  border-radius: 0 0 16px 16px;
}

/* Laymen section styling */
.layman-section {
  background: rgba(34, 197, 94, 0.05);
  border: 1px solid rgba(34, 197, 94, 0.2);
  border-left: 4px solid #22c55e;
  padding: 1.5rem;
  border-radius: 12px;
  margin-bottom: 2rem;
}

.layman-section h3 {
  color: #059669;
  margin-bottom: 1rem;
  font-size: 1.3rem;
}

.layman-section ul {
  margin: 1rem 0;
  padding-left: 1.5rem;
  color: #374151;
}

.layman-section li {
  margin: 0.5rem 0;
  line-height: 1.6;
}

.layman-section em {
  color: #6b7280;
  font-style: italic;
  display: block;
  margin-top: 1rem;
  padding: 1rem;
  background: #f9fafb;
  border-radius: 8px;
  border-left: 3px solid #22c55e;
}

/* Technical section styling */
.tech-section {
  margin: 1rem 0;
  border: 1px solid rgba(139, 92, 246, 0.3);
  border-radius: 12px;
  overflow: hidden;
}

.tech-section summary {
  padding: 1.25rem 1.5rem;
  background: rgba(139, 92, 246, 0.15);
  cursor: pointer;
  font-weight: 600;
  font-size: 1.1rem;
  color: #c4b5fd;
  transition: all 0.3s ease;
  border: none;
}

.tech-section summary:hover {
  background: rgba(139, 92, 246, 0.25);
}

.tech-section[open] summary {
  border-bottom: 1px solid rgba(139, 92, 246, 0.3);
}

.tech-content {
  padding: 1.5rem;
  background: rgba(15, 23, 42, 0.4);
  line-height: 1.7;
}

.tech-content h4 {
  color: #a78bfa;
  margin: 1.5rem 0 1rem 0;
  font-size: 1.1rem;
  font-weight: 600;
}

.tech-content ul {
  margin: 1rem 0;
  padding-left: 1.5rem;
}

.tech-content li {
  margin: 0.75rem 0;
}

/* Tone fields display */
.tone-fields {
  display: grid;
  gap: 1rem;
  margin: 1.5rem 0;
}

@media (min-width: 768px) {
  .tone-fields {
    grid-template-columns: repeat(2, 1fr);
  }
}

.field-item {
  background: #ffffff;
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-left: 4px solid #3b82f6;
  padding: 1rem;
  border-radius: 8px;
  font-size: 0.95rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  color: #374151;
}

/* Mathematical equation styling */
.equation {
  background: #f8fafc;
  border: 1px solid rgba(139, 92, 246, 0.3);
  padding: 1.5rem;
  border-radius: 8px;
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 1.1rem;
  text-align: center;
  margin: 1.5rem 0;
  color: #7c3aed;
  letter-spacing: 1px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* Highlight box */
.highlight {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.1) 0%, rgba(139, 92, 246, 0.1) 100%);
  border: 1px solid rgba(139, 92, 246, 0.3);
  padding: 1.5rem;
  border-radius: 12px;
  margin: 1.5rem 0;
  text-align: center;
  font-weight: 600;
  font-size: 1.1rem;
  color: #1e293b;
}

/* Mobile optimizations for documentation */
@media (max-width: 767px) {
  .docs-content {
    padding: 1rem;
  }
  
  .layman-section, .tech-content {
    padding: 1rem;
  }
  
  .main-docs summary.docs-header {
    padding: 1rem;
    font-size: 1.1rem;
  }
  
  .tone-fields {
    grid-template-columns: 1fr;
  }
  
  .equation {
    font-size: 0.9rem;
    padding: 1rem;
  }
}

/* Preset library styling */
.preset-section {
  margin-bottom: 2rem;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  border-left: 4px solid #007bff;
  overflow: hidden;
}

.preset-main-accordion {
  width: 100%;
}

.preset-main-header {
  padding: 1.5rem;
  background: #f8f9fa;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.3s ease;
  user-select: none;
}

.preset-main-header:hover {
  background: #e9ecef;
}

.preset-main-header:active {
  background: #dee2e6;
  transform: scale(0.98);
}

.preset-header-content {
  flex: 1;
}

.preset-header-content h3 {
  color: #495057;
  margin-bottom: 0.5rem;
  font-size: 1.2rem;
  margin: 0 0 0.5rem 0;
}

.preset-header-content p {
  color: #6c757d;
  margin: 0;
  font-size: 0.95rem;
}

.preset-main-icon {
  font-size: 1rem;
  transition: transform 0.3s ease;
  color: #6c757d;
  font-weight: bold;
}

.preset-main-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.5s ease-out;
  background: white;
}

.preset-main-content.expanded {
  max-height: 3000px;
  transition: max-height 0.6s ease-in;
}

/* Preset search */
.preset-search {
  position: relative;
  margin-bottom: 1.5rem;
}

#presetSearch {
  width: 100%;
  padding: 0.75rem 1rem;
  background: white;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  color: #495057;
  font-size: 0.95rem;
}

#presetSearch:focus {
  border-color: #007bff;
  box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  max-height: 300px;
  overflow-y: auto;
  z-index: 1000;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.search-results.hidden {
  display: none;
}

.search-result-item {
  padding: 1rem;
  cursor: pointer;
  border-bottom: 1px solid #f1f3f4;
  transition: background 0.2s ease;
}

.search-result-item:hover {
  background: #f8f9fa;
}

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

.result-name {
  font-weight: 600;
  color: #212529;
  margin-bottom: 0.25rem;
}

.result-equation {
  font-family: 'Consolas', 'Monaco', monospace;
  color: #6f42c1;
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
}

.result-meta {
  font-size: 0.8rem;
  color: #6c757d;
}

.no-results {
  padding: 1rem;
  text-align: center;
  color: #6c757d;
  font-style: italic;
}

/* Preset categories */
.preset-categories {
  padding: 1rem;
}

.accordion-item {
  margin: 0.75rem 0;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
  background: white;
}

.accordion-header {
  padding: 1rem;
  background: #f8f9fa;
  cursor: pointer;
  font-weight: 600;
  color: #495057;
  transition: all 0.3s ease;
  border: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
  position: relative;
}

.accordion-header:hover {
  background: #e9ecef;
}

.accordion-title {
  flex: 1;
}

.accordion-icon {
  font-size: 0.8rem;
  transition: transform 0.3s ease;
  color: #6c757d;
}

.accordion-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease-out, padding 0.3s ease;
  background: white;
  border-top: 1px solid #e2e8f0;
}

.accordion-content.expanded {
  max-height: 2000px;
  transition: max-height 0.5s ease-in, padding 0.3s ease;
}

.accordion-header:active {
  background: #dee2e6;
  transform: scale(0.98);
}

.preset-list {
  padding: 0.5rem;
  background: white;
}

.preset-item {
  padding: 1rem;
  margin: 0.5rem 0;
  background: white;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.preset-item:hover {
  background: #f8f9fa;
  border-color: #007bff;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.preset-name {
  font-weight: 600;
  color: #212529;
  margin-bottom: 0.5rem;
  font-size: 1rem;
}

.preset-equation {
  font-family: 'Consolas', 'Monaco', monospace;
  color: #6f42c1;
  background: #f8f9fa;
  padding: 0.5rem;
  border-radius: 4px;
  margin: 0.5rem 0;
  font-size: 0.9rem;
  overflow-x: auto;
  border: 1px solid #e9ecef;
}

.preset-description {
  color: #6c757d;
  font-size: 0.9rem;
  margin: 0.5rem 0;
  line-height: 1.4;
}

.preset-category-tag {
  display: inline-block;
  background: #e7f3ff;
  color: #0066cc;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 500;
  margin-top: 0.5rem;
  border: 1px solid #cce7ff;
}

/* Mobile optimizations for presets */
@media (max-width: 767px) {
  .preset-section {
    padding: 1rem;
  }
  
  .preset-item {
    padding: 0.75rem;
  }
  
  .preset-equation {
    font-size: 0.8rem;
  }
  
  .search-results {
    max-height: 250px;
  }
}

/* Authentication modal styling */
.auth-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-container.hidden {
  display: none;
}

.auth-modal {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 20px;
  padding: 2rem;
  max-width: 400px;
  width: 90%;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

.auth-modal h3 {
  color: #1e293b;
  margin-bottom: 1rem;
  font-size: 1.5rem;
}

.auth-modal p {
  color: #475569;
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

.auth-form {
  margin-bottom: 1rem;
}

#usernameInput {
  width: 100%;
  padding: 1rem;
  margin-bottom: 1rem;
  background: #ffffff;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  color: #1e293b;
  font-size: 1rem;
  text-align: center;
}

#usernameInput:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

#loginBtn, #guestBtn {
  width: 100%;
  margin: 0.5rem 0;
  padding: 1rem;
  border-radius: 12px;
  font-weight: 600;
  font-size: 1rem;
}

#loginBtn {
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  color: white;
}

#guestBtn {
  background: #f8fafc;
  color: #64748b;
  border: 1px solid #e2e8f0;
}

#guestBtn:hover {
  background: #f1f5f9;
  color: #475569;
}

.auth-info {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(148, 163, 184, 0.2);
}

.auth-info small {
  color: #64748b;
  font-size: 0.85rem;
}

/* User status styling */
#userStatus {
  margin: 0;
  padding: 0.75rem 1rem;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  text-align: right;
  min-width: 200px;
}

.user-info, .guest-info {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.75rem;
  font-size: 0.9rem;
}

.logout-btn, .login-btn {
  padding: 0.5rem 1rem;
  background: #3b82f6;
  color: #ffffff;
  border: 1px solid #3b82f6;
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

.logout-btn:hover, .login-btn:hover {
  background: #1d4ed8;
  color: #ffffff;
}

/* Mobile optimizations for auth */
@media (max-width: 767px) {
  .auth-modal {
    padding: 1.5rem;
    margin: 1rem;
  }
  
  .user-info, .guest-info {
    flex-direction: column;
    text-align: center;
  }
  
  .logout-btn, .login-btn {
    width: 100%;
  }
}

/* Spectral Binary Simulator Styling */
.spectral-container {
  background: #ffffff;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  margin: 1rem 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  position: relative;
  overflow: hidden;
}

.spectral-container.fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 9999;
  border-radius: 0;
  margin: 0;
}

.spectral-header {
  background: linear-gradient(135deg, #8b5cf6 0%, #3b82f6 100%);
  color: white;
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.spectral-header h3 {
  margin: 0;
  font-size: 1.2rem;
  flex: 1;
}

.spectral-controls {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.resize-btn, .close-btn {
  padding: 0.5rem 0.75rem;
  border: none;
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.resize-btn {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.resize-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.close-btn {
  background: rgba(239, 68, 68, 0.8);
  color: white;
  border: 1px solid rgba(239, 68, 68, 0.5);
}

.close-btn:hover {
  background: rgba(239, 68, 68, 1);
}

.spectral-iframe-wrapper {
  width: 100%;
  height: 600px;
  position: relative;
  background: #f8fafc;
}

.spectral-iframe-wrapper iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

.spectral-resize-handle {
  width: 100%;
  height: 8px;
  background: #e2e8f0;
  cursor: ns-resize;
  position: relative;
  border-top: 1px solid #cbd5e1;
}

.spectral-resize-handle:hover {
  background: #cbd5e1;
}

.spectral-resize-handle::after {
  content: '⋯';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  color: #64748b;
  font-size: 1rem;
  letter-spacing: 2px;
}

.spectral-note {
  padding: 0.75rem 1rem;
  color: #64748b;
  font-size: 0.9rem;
  margin: 0;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
  text-align: center;
}

/* Mobile optimizations for spectral simulator */
@media (max-width: 767px) {
  .spectral-header {
    flex-direction: column;
    text-align: center;
    gap: 0.75rem;
  }
  
  .spectral-controls {
    justify-content: center;
  }
  
  .resize-btn, .close-btn {
    padding: 0.4rem 0.6rem;
    font-size: 0.8rem;
  }
  
  .spectral-iframe-wrapper {
    height: 500px;
  }
}

/* Mobile optimizations for header */
@media (max-width: 767px) {
  .header-content {
    flex-direction: column;
    gap: 1.5rem;
    align-items: center;
  }
  
  .header-left {
    flex-direction: column;
    gap: 1rem;
    text-align: center;
  }
  
  .header-right {
    width: 100%;
    min-width: auto;
  }
  
  #userStatus {
    text-align: center;
    min-width: auto;
    width: 100%;
  }
  
  .user-info, .guest-info {
    justify-content: center;
    flex-direction: column;
    text-align: center;
    gap: 0.5rem;
  }
  
  .logo {
    width: 60px;
    height: 60px;
  }
  
  .title-section {
    text-align: center;
  }
  
  header h1 {
    font-size: clamp(0.65rem, 2.5vw, 1rem);
    margin-bottom: 0.5rem;
  }
  
  header p {
    font-size: clamp(0.64rem, 2vw, 0.76rem);
    max-width: none;
  }
}

@media (min-width: 768px) and (max-width: 1023px) {
  .header-content {
    gap: 1.5rem;
  }
  
  .logo {
    width: 70px;
    height: 70px;
  }
  
  header h1 {
    font-size: clamp(1.4rem, 4vw, 2.2rem);
  }
}
