/* Comfortable Minimal Design System */
:root {
    /* Lighter Color Palette - Comfortable Dark Theme */
    --bg-primary: #1a1d23;
    --bg-secondary: #242831;
    --bg-tertiary: #2d3139;
    --bg-glass: rgba(45, 49, 57, 0.8);
    --bg-card: rgba(36, 40, 49, 0.95);
  
    --text-primary: #f1f3f4;
    --text-secondary: #c9cccf;
    --text-muted: #9aa0a6;
  
    --accent-primary: #4285f4;
    --accent-secondary: #34a853;
    --accent-tertiary: #ea4335;
    --accent-glow: rgba(66, 133, 244, 0.2);
  
    --border-subtle: rgba(241, 243, 244, 0.12);
    --border-medium: rgba(241, 243, 244, 0.2);
  
    /* Spacing System */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;
    --space-16: 4rem;
    --space-20: 5rem;
  
    /* Typography */
    --font-mono: "SF Mono", "Monaco", "Inconsolata", "Roboto Mono", monospace;
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif;
  
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 1.875rem;
  
    /* Radius - More Square */
    --radius-sm: 0.25rem;
    --radius-md: 0.375rem;
    --radius-lg: 0.5rem;
    --radius-xl: 0.75rem;
    --radius-input: 0.5rem; /* Squarish for inputs */
    --radius-full: 9999px;
  
    /* Shadows & Effects */
    --shadow-glow: 0 0 16px var(--accent-glow);
    --shadow-subtle: 0 1px 3px rgba(0, 0, 0, 0.2);
    --shadow-medium: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-large: 0 8px 32px rgba(0, 0, 0, 0.4);
  
    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
  }
  
  /* Reset & Base */
  *,
  *::before,
  *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
  }
  
  body {
    font-family: var(--font-sans);
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
    color: var(--text-primary);
    overflow: hidden;
    min-height: 100vh;
    position: relative;
    font-size: var(--text-base);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }
  
  /* Static geometric background elements - no spinning */
  body::before {
    content: "";
    position: fixed;
    inset: 0;
    /* Subtle dots pattern */
    background-image: radial-gradient(circle at 25% 25%, rgba(66, 133, 244, 0.03) 1px, transparent 1px),
      radial-gradient(circle at 75% 75%, rgba(52, 168, 83, 0.03) 1px, transparent 1px);
    background-size: 60px 60px, 80px 80px;
    pointer-events: none;
    z-index: 1;
  }
  
  /* Additional static geometric shapes */
  body::after {
    content: "";
    position: fixed;
    inset: 0;
    /* Static geometric lines */
    background-image: linear-gradient(45deg, transparent 49%, rgba(241, 243, 244, 0.02) 50%, transparent 51%),
      linear-gradient(-45deg, transparent 49%, rgba(241, 243, 244, 0.02) 50%, transparent 51%);
    background-size: 120px 120px;
    pointer-events: none;
    z-index: 1;
  }
  
  /* Scene Container */
  #scene-container {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
  }
  
  /* Static accent shapes - no animation */
  #scene-container::before {
    content: "";
    position: absolute;
    top: 10%;
    right: 15%;
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, rgba(66, 133, 244, 0.05) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
  }
  
  #scene-container::after {
    content: "";
    position: absolute;
    bottom: 20%;
    left: 10%;
    width: 150px;
    height: 150px;
    background: radial-gradient(circle, rgba(52, 168, 83, 0.04) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
  }
  
  /* Input Container - Perfectly Centered */
  #input-container {
    position: fixed;
    bottom: var(--space-8);
    left: 50%;
    transform: translateX(-50%);
    width: min(90vw, 600px);
    z-index: 100;
    display: flex;
    gap: var(--space-3);
    align-items: center;
  }
  
  /* Text Input - More Squarish */
  #text-input {
    flex: 1;
    padding: var(--space-5) var(--space-6);
    font-size: var(--text-lg);
    font-family: var(--font-sans);
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-input); /* More square */
    color: var(--text-primary);
    outline: none;
    transition: all var(--transition-base);
    box-shadow: var(--shadow-subtle);
    min-height: 56px;
    resize: none;
  }
  
  #text-input::placeholder {
    color: var(--text-muted);
    font-weight: 400;
  }
  
  #text-input:focus {
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-glow), var(--shadow-medium);
    transform: translateY(-1px);
  }
  
  #text-input:hover:not(:focus) {
    border-color: var(--border-medium);
    transform: translateY(-0.5px);
  }
  
  /* Voice Select - More Squarish */
  #voice-select {
    padding: var(--space-4) var(--space-5);
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-input); /* More square */
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    outline: none;
    cursor: pointer;
    transition: all var(--transition-base);
    min-width: 140px;
    box-shadow: var(--shadow-subtle);
  }
  
  #voice-select:hover,
  #voice-select:focus {
    border-color: var(--accent-primary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-glow), var(--shadow-medium);
  }
  
  /* Microphone Button with Real Icon */
  .mic-button {
    padding: var(--space-4);
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-input);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-base);
    box-shadow: var(--shadow-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 56px;
    min-height: 56px;
  }
  
  .mic-button:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-glow), var(--shadow-medium);
  }
  
  .mic-button.active {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
  }
  
  /* Microphone SVG Icon - Using CSS to create the icon */
  .mic-icon {
    width: 20px;
    height: 20px;
    position: relative;
  }
  
  .mic-icon::before {
    content: "";
    position: absolute;
    top: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 8px;
    height: 12px;
    background: currentColor;
    border-radius: 4px 4px 0 0;
    border: 2px solid currentColor;
    background: transparent;
  }
  
  .mic-icon::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 16px;
    height: 8px;
    border: 2px solid currentColor;
    border-top: none;
    border-radius: 0 0 8px 8px;
    background: transparent;
  }
  
  /* Add the stand for the microphone */
  .mic-button::after {
    content: "";
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: 6px;
    background: currentColor;
  }
  
  /* Status Indicator - Top Left */
  #status {
    position: fixed;
    top: var(--space-6);
    left: var(--space-6);
    padding: var(--space-3) var(--space-4);
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    font-size: var(--text-xs);
    font-family: var(--font-mono);
    color: var(--text-secondary);
    pointer-events: none;
    z-index: 90;
    box-shadow: var(--shadow-subtle);
    text-transform: uppercase;
    letter-spacing: 0.05em;
  }
  
  /* Speech Bubble - Redesigned as Streaming Comment Box */
  #speech-bubble {
    position: fixed;
    top: 50%;
    right: var(--space-6);
    transform: translateY(-50%);
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-subtle);
    padding: var(--space-4) var(--space-5);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-large);
  
    /* Narrow streaming comment box */
    width: 280px;
    max-width: 280px;
    min-height: 60px;
    max-height: 400px;
  
    opacity: 0;
    transition: all var(--transition-slow);
    z-index: 1000;
    font-size: var(--text-sm);
    line-height: 1.5;
    color: var(--text-primary);
  
    /* Scrollable for long content */
    overflow-y: auto;
    overflow-x: hidden;
    word-wrap: break-word;
    hyphens: auto;
  }
  
  #speech-bubble.show {
    opacity: 1;
    transform: translateY(-50%) translateX(-8px);
  }
  
  /* Left-pointing arrow for speech bubble */
  #speech-bubble::after {
    content: "";
    position: absolute;
    left: -6px;
    top: 20px;
    width: 12px;
    height: 12px;
    background: var(--bg-card);
    border-left: 1px solid var(--border-subtle);
    border-bottom: 1px solid var(--border-subtle);
    border-radius: 0 0 0 var(--radius-sm);
    rotate: 45deg;
  }
  
  /* Streaming text effect */
  #speech-bubble .streaming-text {
    display: inline;
  }
  
  #speech-bubble .streaming-cursor {
    display: inline-block;
    width: 2px;
    height: 1em;
    background: var(--accent-primary);
    margin-left: 2px;
    animation: blink 1s infinite;
  }
  
  @keyframes blink {
    0%,
    50% {
      opacity: 1;
    }
    51%,
    100% {
      opacity: 0;
    }
  }
  
  /* Custom scrollbar for speech bubble */
  #speech-bubble::-webkit-scrollbar {
    width: 4px;
  }
  
  #speech-bubble::-webkit-scrollbar-track {
    background: transparent;
  }
  
  #speech-bubble::-webkit-scrollbar-thumb {
    background: var(--border-medium);
    border-radius: var(--radius-sm);
  }
  
  #speech-bubble::-webkit-scrollbar-thumb:hover {
    background: var(--border-subtle);
  }
  
  /* Loading - Simple Dots Instead of Spinner */
  #loading {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 1000;
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    padding: var(--space-8);
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-large);
  }
  
  /* Simple loading dots - no spinning */
  .loader {
    display: flex;
    gap: var(--space-2);
    justify-content: center;
    margin: 0 auto var(--space-4);
  }
  
  .loader-dot {
    width: 8px;
    height: 8px;
    background: var(--accent-primary);
    border-radius: 50%;
    animation: pulse 1.5s ease-in-out infinite;
  }
  
  .loader-dot:nth-child(2) {
    animation-delay: 0.3s;
  }
  
  .loader-dot:nth-child(3) {
    animation-delay: 0.6s;
  }
  
  @keyframes pulse {
    0%,
    100% {
      opacity: 0.3;
      transform: scale(0.8);
    }
    50% {
      opacity: 1;
      transform: scale(1);
    }
  }
  
  /* Debug Panel */
  #debug {
    position: fixed;
    top: var(--space-16);
    left: var(--space-6);
    padding: var(--space-4);
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    font-size: var(--text-xs);
    font-family: var(--font-mono);
    max-height: 200px;
    overflow-y: auto;
    width: 300px;
    color: var(--text-secondary);
    box-shadow: var(--shadow-medium);
    line-height: 1.4;
  }
  
  #debug::-webkit-scrollbar {
    width: 4px;
  }
  
  #debug::-webkit-scrollbar-track {
    background: transparent;
  }
  
  #debug::-webkit-scrollbar-thumb {
    background: var(--border-medium);
    border-radius: var(--radius-sm);
  }
  
  /* Controls - Top Right */
  #controls {
    position: fixed;
    top: var(--space-6);
    right: var(--space-6);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    z-index: 100;
  }
  
  .control-button {
    padding: var(--space-3) var(--space-4);
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    cursor: pointer;
    font-size: var(--text-xs);
    font-family: var(--font-sans);
    font-weight: 500;
    transition: all var(--transition-base);
    box-shadow: var(--shadow-subtle);
    text-transform: uppercase;
    letter-spacing: 0.05em;
  }
  
  .control-button:hover {
    border-color: var(--accent-primary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-glow), var(--shadow-medium);
  }
  
  .control-button:active {
    transform: translateY(0);
  }
  
  /* Voice Type Container */
  #voice-type-container {
    position: fixed;
    bottom: 200px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: var(--space-2);
    justify-content: center;
    flex-wrap: wrap;
    max-width: min(90vw, 600px);
  }
  
  .voice-type-option {
    padding: var(--space-2) var(--space-4);
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg); /* More square */
    cursor: pointer;
    transition: all var(--transition-base);
    font-size: var(--text-xs);
    font-weight: 500;
    color: var(--text-secondary);
    box-shadow: var(--shadow-subtle);
    text-transform: uppercase;
    letter-spacing: 0.05em;
  }
  
  .voice-type-option:hover {
    color: var(--text-primary);
    border-color: var(--border-medium);
    transform: translateY(-1px);
  }
  
  .voice-type-option.active {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-glow), var(--shadow-medium);
  }
  
  /* Error Message */
  #error-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--accent-tertiary);
    padding: var(--space-8);
    border-radius: var(--radius-xl);
    max-width: min(85vw, 400px);
    text-align: center;
    z-index: 1000;
    display: none;
    box-shadow: 0 0 20px rgba(234, 67, 53, 0.2), var(--shadow-large);
  }
  
  #error-message h3 {
    color: var(--accent-tertiary);
    margin-bottom: var(--space-4);
    font-size: var(--text-xl);
    font-weight: 600;
  }
  
  #error-message p {
    margin-bottom: var(--space-6);
    color: var(--text-secondary);
    line-height: 1.5;
  }
  
  #error-message button {
    padding: var(--space-3) var(--space-6);
    background: var(--accent-primary);
    color: white;
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    font-weight: 500;
    transition: all var(--transition-base);
    font-family: inherit;
    font-size: var(--text-sm);
  }
  
  #error-message button:hover {
    background: #3367d6;
    transform: translateY(-1px);
    box-shadow: var(--shadow-glow);
  }
  
  /* Settings Panel */
  .settings-panel {
    position: fixed;
    top: var(--space-6);
    right: var(--space-6);
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    padding: var(--space-6);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-large);
    z-index: 100;
    border: 1px solid var(--border-subtle);
    min-width: 280px;
  }
  
  .settings-row {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    margin-bottom: var(--space-4);
  }
  
  .settings-row:last-child {
    margin-bottom: 0;
  }
  
  .settings-row label {
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-primary);
    min-width: 80px;
  }
  
  .settings-row input[type="range"] {
    flex: 1;
    accent-color: var(--accent-primary);
    background: transparent;
  }
  
  /* Voice Button */
  .voice-button {
    padding: var(--space-5) var(--space-8);
    font-size: var(--text-xl);
    font-weight: 600;
    border-radius: var(--radius-lg); /* More square */
    border: 2px solid var(--accent-primary);
    background: transparent;
    color: var(--accent-primary);
    cursor: pointer;
    transition: all var(--transition-base);
    font-family: inherit;
    box-shadow: var(--shadow-medium);
    backdrop-filter: blur(20px);
  }
  
  .voice-button:hover {
    background: var(--accent-primary);
    color: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow), var(--shadow-large);
  }
  
  .voice-button:active {
    transform: translateY(-1px);
  }
  
  /* Audio Debug */
  #audio-debug {
    position: fixed;
    bottom: 120px;
    left: 50%;
    transform: translateX(-50%);
    width: 300px;
    height: 48px;
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border-radius: var(--radius-lg);
    display: none;
    box-shadow: var(--shadow-subtle);
    border: 1px solid var(--border-subtle);
  }
  
  #audio-canvas {
    width: 100%;
    height: 100%;
    border-radius: var(--radius-lg);
  }
  
  /* Responsive Design */
  @media (max-width: 768px) {
    #input-container {
      width: calc(100vw - var(--space-8));
      bottom: var(--space-6);
      flex-direction: column;
      gap: var(--space-3);
    }
  
    #voice-select {
      width: 100%;
      min-width: auto;
    }
  
    /* Move speech bubble to top on mobile to avoid covering character */
    #speech-bubble {
      top: var(--space-6);
      right: var(--space-4);
      left: var(--space-4);
      width: auto;
      max-width: none;
      transform: none;
    }
  
    #speech-bubble.show {
      transform: translateY(8px);
    }
  
    /* Adjust arrow for mobile */
    #speech-bubble::after {
      display: none;
    }
  
    #voice-type-container {
      bottom: 240px;
      max-width: calc(100vw - var(--space-8));
    }
  
    .settings-panel,
    #status,
    #debug {
      left: var(--space-4);
      right: var(--space-4);
      width: auto;
    }
  
    #controls {
      right: var(--space-4);
    }
  }
  
  @media (max-width: 480px) {
    #text-input {
      font-size: var(--text-base);
      padding: var(--space-4) var(--space-5);
      min-height: 48px;
    }
  
    .voice-button {
      padding: var(--space-4) var(--space-6);
      font-size: var(--text-lg);
    }
  
    #speech-bubble {
      padding: var(--space-3) var(--space-4);
      font-size: var(--text-xs);
      width: calc(100vw - var(--space-6));
      left: var(--space-3);
      right: var(--space-3);
    }
  }
  
  /* Accessibility */
  @media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important;
    }
  }
  
  *:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
  }
  
  /* Selection */
  ::selection {
    background: var(--accent-primary);
    color: white;
  }
  
  /* Scrollbar Styling */
  ::-webkit-scrollbar {
    width: 6px;
  }
  
  ::-webkit-scrollbar-track {
    background: transparent;
  }
  
  ::-webkit-scrollbar-thumb {
    background: var(--border-medium);
    border-radius: var(--radius-sm);
  }
  
  ::-webkit-scrollbar-thumb:hover {
    background: var(--border-subtle);
  }
  
