/**
 * Mila - Auto-Friendly Styling
 * Large text, high contrast, minimal distractions
 * THEME: Customizable by user
 */

:root {
  /* User-customizable theme colors (defaults: black bg + cyan buttons) */
  --theme-bg: #000000;
  --theme-primary: #00D4FF;

  /* Auto-calculated based on theme */
  --bg-dark: var(--theme-bg);
  --bg-card: color-mix(in srgb, var(--theme-bg) 85%, white);
  --text-primary: #ffffff;  /* Will be set dynamically based on bg */
  --text-secondary: color-mix(in srgb, var(--text-primary) 70%, var(--theme-bg));

  /* Primary color variations */
  --color-primary: var(--theme-primary);
  --color-primary-rgb: 0, 212, 255;  /* RGB for rgba() usage, updated when theme changes */
  --color-primary-hover: color-mix(in srgb, var(--theme-primary) 85%, black);
  --color-primary-light: color-mix(in srgb, var(--theme-primary) 50%, white);

  /* Fixed UI colors */
  --color-secondary: #2196F3;
  --color-warning: #FF9800;
  --color-error: #f44336;
  --color-success: #4CAF50;
  --color-accent: #9C27B0;
}

/* Dark background theme (white text) */
body[data-theme="dark"] {
  --text-primary: #ffffff;
  --text-secondary: #b0b0b0;
}

/* Light background theme (black text) */
body[data-theme="light"] {
  --text-primary: #000000;
  --text-secondary: #505050;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  font-size: 18px;
  line-height: 1.6;
}

/* ===================
   SPLASH SCREEN
   =================== */

.splash-screen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-dark);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.5s ease-out;
}

.splash-screen.hidden {
  opacity: 0;
  pointer-events: none;
}

.splash-logo {
  max-width: 300px;
  width: 80%;
  height: auto;
  margin-bottom: 24px;
  animation: fadeInScale 1s ease-out;
}

.splash-title {
  font-size: 48px;
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: 8px;
  animation: fadeInUp 1s ease-out 0.3s backwards;
}

.splash-subtitle {
  font-size: 20px;
  color: var(--text-secondary);
  margin-bottom: 32px;
  animation: fadeInUp 1s ease-out 0.5s backwards;
}

.splash-subtitle-logo {
  max-width: 240px;  /* 80% of splash-logo (300px) */
  width: 64%;  /* 80% of splash-logo width (80%) */
  height: auto;
  margin-bottom: 32px;
  animation: fadeInUp 1s ease-out 0.5s backwards;
}

.splash-loader {
  width: 50px;
  height: 50px;
  border: 4px solid #333;
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

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

/* ===================
   AUTH PAGES
   =================== */

.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.auth-container {
  width: 100%;
  max-width: 480px;
}

.auth-card {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 40px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.auth-card h1 {
  font-size: 42px;
  text-align: center;
  margin-bottom: 8px;
}

.subtitle {
  text-align: center;
  color: var(--text-secondary);
  margin-bottom: 32px;
  font-size: 18px;
}

.info-box {
  background: rgba(33, 150, 243, 0.1);
  border-left: 4px solid var(--color-secondary);
  padding: 16px;
  margin-bottom: 24px;
  border-radius: 8px;
  font-size: 16px;
}

.auth-form {
  margin-bottom: 24px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  font-size: 16px;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 14px;
  font-size: 18px;
  background: var(--bg-dark);
  border: 2px solid #444;
  border-radius: 8px;
  color: var(--text-primary);
  transition: border-color 0.3s;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--color-primary);
}

.form-group small {
  display: block;
  margin-top: 6px;
  color: var(--text-secondary);
  font-size: 14px;
}

.color-picker-group {
  display: flex;
  gap: 12px;
  align-items: center;
}

.color-picker-group input[type="color"] {
  width: 60px;
  height: 50px;
  padding: 4px;
  border-radius: 8px;
  cursor: pointer;
}

.color-picker-group input[type="text"] {
  flex: 1;
  font-family: monospace;
  text-transform: uppercase;
}

.color-picker-group.disabled {
  opacity: 0.5;
  pointer-events: none;
}

.color-preset-option {
  display: flex;
  align-items: center;
  margin-bottom: 12px;
  padding: 12px;
  border: 2px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.color-preset-option:hover {
  background: rgba(255, 255, 255, 0.05);
}

.color-preset-option input[type="radio"]:checked ~ .preset-label {
  font-weight: 600;
  color: var(--color-primary);
}

.preset-preview {
  display: flex;
  gap: 6px;
  margin-left: auto;
}

.preset-preview-color {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-reset {
  padding: 12px 20px;
  font-size: 14px;
  background: var(--color-secondary);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.3s;
}

.btn-reset:hover {
  background: #1976D2;
}

.btn {
  width: 100%;
  padding: 16px;
  font-size: 20px;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

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

.btn-primary:hover:not(:disabled) {
  background: #45a049;
  transform: translateY(-2px);
}

.btn-primary:disabled {
  background: #666;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--color-secondary);
  color: white;
  padding: 12px 24px;
  font-size: 18px;
  width: auto;
}

.error-message {
  color: var(--color-error);
  margin-top: 16px;
  font-size: 16px;
  min-height: 24px;
}

.success-message {
  color: var(--color-primary);
  margin-top: 16px;
  font-size: 16px;
  min-height: 24px;
}

.auth-links {
  text-align: center;
  margin-top: 24px;
}

.auth-links a {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 500;
}

.auth-links a:hover {
  text-decoration: underline;
}

/* ===================
   CHAT PAGE
   =================== */

.chat-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
}

.chat-header {
  background: var(--bg-card);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid #333;
}

.chat-header h1 {
  font-size: 32px;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 18px;
}

.btn-icon {
  background: transparent;
  border: none;
  font-size: 28px;
  cursor: pointer;
  padding: 8px;
  transition: transform 0.2s;
}

.btn-icon:hover {
  transform: scale(1.1);
}

.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  height: calc(100vh - 70px); /* Full height minus header */
}

.chat-messages {
  flex: 2;  /* 40% - Chat history */
  overflow-y: auto;
  padding: 20px;
  border-bottom: 1px solid #333;
}

.message-input-area {
  flex: 1;  /* 20% - Message/instruction area */
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid #333;
  background: rgba(255, 255, 255, 0.02);
}

.message {
  margin-bottom: 20px;
  padding: 20px;
  border-radius: 12px;
  max-width: 85%;
  font-size: 20px;
}

.message-user {
  background: rgba(33, 150, 243, 0.2);
  border-left: 4px solid var(--color-secondary);
  margin-left: auto;
}

.message-assistant {
  background: rgba(76, 175, 80, 0.2);
  border-left: 4px solid var(--color-primary);
}

.message-system {
  background: rgba(255, 152, 0, 0.2);
  border-left: 4px solid var(--color-warning);
  text-align: center;
  max-width: 100%;
  font-size: 18px;
}

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

.message-time {
  font-size: 14px;
  color: var(--text-secondary);
  text-align: right;
}

/* Microphone Status */
.mic-status {
  text-align: center;
  padding: 12px;
  margin: 10px 0;
}

.mic-indicator {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  margin: 0 auto 8px;
  transition: all 0.3s;
}

.mic-inactive {
  background: var(--color-error);
}

.mic-idle {
  background: #888;
  animation: pulse-slow 3s infinite;
}

.mic-listening {
  background: var(--color-primary);
  animation: pulse 1.5s infinite;
}

.mic-processing {
  background: var(--color-secondary);
  animation: spin 1s linear infinite;
}

.mic-speaking {
  background: var(--color-warning);
  animation: pulse 1s infinite;
}

.mic-error {
  background: var(--color-error);
  animation: shake 0.5s;
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.1);
    opacity: 0.8;
  }
}

@keyframes pulse-slow {
  0%, 100% {
    transform: scale(1);
    opacity: 0.6;
  }
  50% {
    transform: scale(1.05);
    opacity: 0.8;
  }
}

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

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-10px); }
  75% { transform: translateX(10px); }
}

#micText {
  font-size: 22px;
  font-weight: 500;
  color: var(--text-secondary);
}

/* Command Hint */
.command-hint {
  width: 100%;
  max-width: 800px;
  min-height: 40px;
  padding: 12px;
  margin: 10px 0;
  background: linear-gradient(135deg, rgba(79, 195, 247, 0.2), rgba(33, 150, 243, 0.2));
  border: 2px solid var(--color-primary);
  border-radius: 8px;
  text-align: center;
  font-size: 20px;
  font-weight: 600;
  color: var(--color-primary);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  letter-spacing: 0.5px;
  animation: pulse-glow 2s infinite;
}

@keyframes pulse-glow {
  0%, 100% {
    box-shadow: 0 0 10px rgba(79, 195, 247, 0.3);
  }
  50% {
    box-shadow: 0 0 20px rgba(79, 195, 247, 0.6);
  }
}

/* Transcript */
.transcript {
  width: 100%;
  max-width: 800px;
  min-height: 60px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  text-align: center;
  font-size: 24px;
  font-style: italic;
  color: var(--text-secondary);
  word-wrap: break-word;
}

/* Controls */
.chat-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 20px;
  background: var(--bg-card);
  border-top: 2px solid #333;
  overflow-y: auto;
  max-height: 50vh;
}

/* Mode Toggle Button */
.btn-mode-toggle {
  padding: 16px 32px;
  font-size: 20px;
  font-weight: 600;
  background: var(--color-secondary);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.btn-mode-toggle:hover {
  background: #1976D2;
  transform: translateY(-2px);
}

.btn-mode-toggle:active {
  transform: translateY(0);
}

/* Mode Hint */
.mode-hint {
  padding: 12px 24px;
  font-size: 16px;
  color: var(--text-secondary);
  text-align: center;
  font-style: italic;
}

.mode-hint.hidden {
  display: none;
}

.command-hint.hidden {
  display: none;
}

/* Button Mode Controls */
.button-mode-controls {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: 100%;
  max-width: 600px;
  margin: 10px 0;
}

.button-mode-controls.hidden {
  display: none;
}

/* Command Buttons */
.btn-command {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px;
  min-height: 70px;
  background: var(--color-primary);
  border: none;
  border-radius: 8px;
  font-size: 28px;
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: 0 2px 8px rgba(79, 195, 247, 0.4);
}

.btn-command span {
  font-size: 11px;
  font-weight: 600;
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: white;
}

.btn-command:hover {
  background: var(--color-primary-hover);
  transform: translateY(-4px);
  box-shadow: 0 6px 20px rgba(79, 195, 247, 0.6);
}

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

.btn-command:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: var(--bg-card);
  border-radius: 16px;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  padding: 24px;
  border-bottom: 2px solid #333;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  font-size: 28px;
}

.modal-close {
  background: none;
  border: none;
  font-size: 36px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0;
  width: 40px;
  height: 40px;
  line-height: 1;
}

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

.modal-body {
  padding: 24px;
}

.modal-footer {
  padding: 24px;
  border-top: 2px solid #333;
}

.usage-stats {
  margin-top: 24px;
  padding: 20px;
  background: rgba(33, 150, 243, 0.1);
  border-radius: 8px;
}

.usage-stats h3 {
  font-size: 20px;
  margin-bottom: 12px;
}

.usage-stats p {
  font-size: 18px;
  margin-bottom: 8px;
}

/* Loading Indicator */
.loading {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg-card);
  padding: 32px;
  border-radius: 16px;
  text-align: center;
  z-index: 999;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
}

.loading.hidden {
  display: none;
}

.spinner {
  width: 60px;
  height: 60px;
  border: 6px solid #333;
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 16px;
}

.loading p {
  font-size: 18px;
  color: var(--text-secondary);
}
/* Settings Tabs */
.settings-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--bg-card);
  margin-bottom: 24px;
  overflow-x: auto;
}

.settings-tab {
  padding: 12px 20px;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  color: #888;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.settings-tab:hover {
  color: var(--theme-primary);
  background: rgba(255, 255, 255, 0.05);
}

.settings-tab.active {
  color: var(--theme-primary);
  border-bottom-color: var(--theme-primary);
}

.settings-tab-content {
  display: none;
}

.settings-tab-content.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

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

/* Larger modal for settings */
.modal-content-large {
  max-width: 700px;
  max-height: 85vh;
}

.modal-content-large .modal-body {
  max-height: calc(85vh - 180px);
  overflow-y: auto;
}

/* Full-screen modals for settings and help */
.modal-fullscreen {
  padding: 0;
  align-items: stretch;
  justify-content: stretch;
}

.modal-content-fullscreen {
  max-width: 100%;
  max-height: 100vh;
  width: 100%;
  height: 100vh;
  border-radius: 0;
  display: flex;
  flex-direction: column;
}

.modal-content-fullscreen .modal-header {
  flex-shrink: 0;
}

.modal-content-fullscreen .modal-body {
  flex: 1;
  overflow-y: auto;
  max-height: none;
}

.modal-content-fullscreen .modal-content-scrollable {
  flex: 1;
  overflow-y: auto;
  max-height: none;
}

/* Usage Stats Grid */
.usage-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.usage-stat-card {
  background: var(--bg-card);
  padding: 16px;
  border-radius: 12px;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.stat-label {
  font-size: 12px;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.stat-value {
  font-size: 24px;
  font-weight: 600;
  color: var(--theme-primary);
}

/* Subscription Info */
.subscription-info {
  background: var(--bg-card);
  padding: 20px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.subscription-info p {
  margin: 12px 0;
  font-size: 16px;
}

.subscription-info span {
  color: var(--theme-primary);
  font-weight: 600;
}

/* Mobile Optimizations */
@media (max-width: 768px) {
  body {
    font-size: 16px;
  }

  .chat-header h1 {
    font-size: 24px;
  }

  .message {
    font-size: 18px;
    max-width: 90%;
  }

  .mic-indicator {
    width: 60px;
    height: 60px;
  }

  #micText {
    font-size: 18px;
  }

  .transcript {
    font-size: 20px;
  }

  .command-hint {
    font-size: 18px;
    padding: 10px;
  }

  .button-mode-controls {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .btn-command {
    min-height: 65px;
    font-size: 24px;
    padding: 10px;
  }

  .btn-command span {
    font-size: 10px;
  }

  /* Mobile-specific modal improvements */
  .modal-content {
    width: 95%;
    max-height: 85vh;
    overflow-y: auto;
  }

  .settings-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .settings-tab {
    white-space: nowrap;
    min-width: 120px;
  }

  /* Larger touch targets for mobile */
  .btn, .btn-icon, .btn-command {
    min-height: 48px;
    min-width: 48px;
  }

  /* Better input sizing on mobile */
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="color"],
  select {
    font-size: 16px; /* Prevents zoom on iOS */
  }

  /* Hide install prompt on very small screens */
  .install-prompt {
    bottom: 10px;
    width: 95%;
  }
}

/* Landscape mode on mobile */
@media (max-width: 768px) and (orientation: landscape) {
  .chat-container {
    max-height: 60vh;
  }

  .settings-tab-content {
    max-height: 50vh;
    overflow-y: auto;
  }

  .modal-content {
    max-height: 80vh;
  }
}

/* iOS-specific fixes */
@supports (-webkit-touch-callout: none) {
  /* iOS Safe Area */
  body {
    padding-bottom: env(safe-area-inset-bottom);
  }

  .chat-controls {
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
  }

  .install-prompt {
    bottom: calc(20px + env(safe-area-inset-bottom));
  }

  /* Prevent iOS zoom on input focus */
  input, select, textarea {
    font-size: 16px !important;
  }

  /* Fix iOS 100vh issue */
  .chat-container {
    min-height: -webkit-fill-available;
  }
}

/* High DPI / Retina displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  /* Sharper text rendering */
  body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
  /* Remove hover effects on touch devices */
  .btn:hover,
  .btn-icon:hover,
  .settings-tab:hover {
    transform: none;
  }

  /* Add active/pressed states instead */
  .btn:active,
  .btn-icon:active {
    transform: scale(0.95);
    opacity: 0.8;
  }

  /* Larger tap targets */
  .btn, .btn-icon {
    min-height: 56px;
    min-width: 56px;
  }

  /* Better spacing for touch */
  .chat-controls {
    gap: 16px;
  }

  .button-mode-controls {
    gap: 12px;
  }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}

/* PWA Install Prompt */
.install-prompt {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  border: 2px solid var(--theme-primary);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  z-index: 9999;
  max-width: 400px;
  width: 90%;
  animation: slideUp 0.3s ease;
}

.install-prompt.hidden {
  display: none;
}

.install-prompt-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.install-prompt-content p {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.install-prompt .btn {
  width: 100%;
  padding: 12px 24px;
  font-size: 16px;
}

.install-prompt .btn-text {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 8px;
  font-size: 14px;
}

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

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(100px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

/* ===================
   SMART BUTTON SYSTEM
   =================== */

/* Button Container - 2x3 grid (40% of screen) */
.button-container {
  flex: 2;  /* 40% - Button area */
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;  /* 3 equal columns */
  grid-template-rows: 1fr 1fr;  /* 2 equal rows */
  gap: 16px;
  padding: 24px;
  max-width: 1000px;
  margin: 0 auto;
  width: 100%;
  align-content: center;
}

/* Base button styles - all equal size */
.button-container .btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  position: relative;
  overflow: hidden;
  height: 120px;
  font-size: 1.3em;
  border-radius: 20px;
  background: var(--color-primary);
  color: #000;
}

.button-container .btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.button-container .btn:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.button-container .btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Button icon */
.btn-icon {
  font-size: 2em;
  line-height: 1;
}

/* Button label */
.btn-label {
  font-size: 1em;
  line-height: 1;
}

.btn-loading {
  animation: pulse 1.5s infinite;
}

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

/* Button loading spinner */
.btn-loading .btn-icon {
  animation: spin 1s linear infinite;
}

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

/* Responsive adjustments */
@media (max-width: 768px) {
  .button-container {
    gap: 12px;
    padding: 16px;
  }

  .button-container .btn {
    height: 100px;
    font-size: 1.1em;
    border-radius: 16px;
  }

  .btn-icon {
    font-size: 1.8em;
  }
}

@media (max-width: 480px) {
  .button-container {
    gap: 8px;
    padding: 12px;
  }

  .button-container .btn {
    height: 80px;
    font-size: 0.9em;
    border-radius: 12px;
  }

  .btn-icon {
    font-size: 1.5em;
  }
}

/* Car mode - extra large buttons */
@media (min-width: 1200px) {
  .button-container {
    max-width: 1200px;
    gap: 24px;
  }

  .button-container .btn {
    height: 160px;
    font-size: 1.8em;
    border-radius: 24px;
  }

  .btn-icon {
    font-size: 2.5em;
  }
}

/* ==========================================================================
   CAR MODE - 5-MODE SIMPLIFIED UI
   ========================================================================== */

/* Car mode layout - applied when UI_LAYOUT='car-mode-5' */
body.car-mode-layout {
  /* Hide default UI elements in car mode for minimal interface */
}

/* Hide all non-button UI elements in car mode */
body.car-mode-layout #commandHint,
body.car-mode-layout #transcript,
body.car-mode-layout #micStatus,
body.car-mode-layout #chatMessages,
body.car-mode-layout .message-input-area {
  display: none !important;
}

body.car-mode-layout .button-container {
  /* Remove grid, buttons will be positioned absolutely */
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
  height: calc(100vh - 60px); /* Full height minus banner */
  max-width: none;
  width: 100%;
  position: fixed;
  top: 60px;
  left: 0;
  right: 0;
  bottom: 0;
}

/* Car mode large touch targets */
body.car-mode-large-buttons .btn {
  min-height: 80px;
  font-size: 1.5em;
  border-radius: 16px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

body.car-mode-large-buttons .btn-icon {
  font-size: 2.5em;
}

body.car-mode-large-buttons .btn-label {
  font-size: 1.2em;
  font-weight: 700;
}

/* Full screen button (PARK, DRIVE, RESPONSE modes) */
.car-mode-full {
  width: 100%;
  height: 100%;
  min-height: 300px;
  font-size: 2.5em !important;
  border-radius: 0 !important;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
}

.car-mode-full .btn-icon {
  font-size: 4em;
}

.car-mode-full .btn-label {
  font-size: 1.2em;
  font-weight: 800;
}

/* Half screen buttons (RECORDING, NEXT modes) */
.car-mode-half-top {
  width: 100%;
  flex: 1;  /* Use flex instead of height percentage */
  min-height: 0;  /* Allow flex to control sizing */
  font-size: 2em !important;
  border-radius: 0 !important;
  border-bottom: 2px solid var(--color-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 15px;
}

.car-mode-half-bottom {
  width: 100%;
  flex: 1;  /* Use flex instead of height percentage */
  min-height: 0;  /* Allow flex to control sizing */
  font-size: 2em !important;
  border-radius: 0 !important;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 15px;
}

.car-mode-half-top .btn-icon,
.car-mode-half-bottom .btn-icon {
  font-size: 3em;
}

.car-mode-half-top .btn-label,
.car-mode-half-bottom .btn-label {
  font-size: 1.1em;
  font-weight: 700;
}

/* Logo display in DRIVE mode */
.car-mode-show-logo {
  background: linear-gradient(135deg,
    var(--color-bg-primary) 0%,
    var(--color-bg-secondary) 100%);
}

.car-mode-logo {
  width: 200px;
  height: 200px;
  object-fit: contain;
  margin-bottom: 20px;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.2));
}

/* High contrast for daylight visibility */
body.car-mode-layout {
  --color-text-primary: #000;
  --color-text-secondary: #333;
  --color-bg-primary: #fff;
  --color-bg-secondary: #f5f5f5;
  --color-border: #ddd;
}

body.car-mode-layout.dark-mode {
  --color-text-primary: #fff;
  --color-text-secondary: #ccc;
  --color-bg-primary: #1a1a1a;
  --color-bg-secondary: #2a2a2a;
  --color-border: #444;
}

/* Button color variations for car mode */
body.car-mode-layout .btn-listen,
body.car-mode-layout .btn-continue {
  background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
  color: white;
}

body.car-mode-layout .btn-send {
  background: linear-gradient(135deg, #2196F3 0%, #1976D2 100%);
  color: white;
}

body.car-mode-layout .btn-stop {
  background: linear-gradient(135deg, #f44336 0%, #d32f2f 100%);
  color: white;
}

body.car-mode-layout .btn-new-chat {
  background: linear-gradient(135deg, #FF9800 0%, #F57C00 100%);
  color: white;
}

/* Settings button always visible in car mode - user needs access to configure API keys */
body.car-mode-layout #settingsBtn {
  display: block !important;
}

/* Hide irrelevant settings tabs in car mode */
body.car-mode-layout .settings-tab[data-tab="commands"],
body.car-mode-layout .settings-tab[data-tab="subscription"] {
  display: none !important;
}

/* Hide STT engine selection in car mode (Whisper is forced) */
body.car-mode-layout #sttEngineSelect,
body.car-mode-layout #voskModelSelect,
body.car-mode-layout #downloadVoskModelBtn,
body.car-mode-layout label[for="sttEngineSelect"],
body.car-mode-layout label[for="voskModelSelect"] {
  display: none !important;
}

/* Recording indicator animation */
@keyframes recording-pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
  }
  50% {
    box-shadow: 0 0 0 20px rgba(239, 68, 68, 0);
  }
}

/* Apply pulsing animation to RECORDING mode buttons */
body.car-mode-layout .car-mode-half-top,
body.car-mode-layout .car-mode-half-bottom {
  position: relative;
}

body.car-mode-layout .car-mode-half-top::before {
  content: '🔴 RECORDING';
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(239, 68, 68, 0.9);
  color: white;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 0.9em;
  font-weight: 700;
  animation: recording-pulse 1.5s infinite;
  z-index: 10;
}

/* Mobile optimizations for car mode */
@media (max-width: 768px) {
  .car-mode-logo {
    width: 150px;
    height: 150px;
  }

  .car-mode-full {
    font-size: 2em !important;
  }

  .car-mode-half-top,
  .car-mode-half-bottom {
    font-size: 1.5em !important;
  }
}

@media (max-width: 480px) {
  .car-mode-logo {
    width: 120px;
    height: 120px;
  }

  .car-mode-full {
    font-size: 1.5em !important;
  }

  .car-mode-half-top,
  .car-mode-half-bottom {
    font-size: 1.2em !important;
  }

  .car-mode-full .btn-icon,
  .car-mode-half-top .btn-icon,
  .car-mode-half-bottom .btn-icon {
    font-size: 2.5em;
  }
}

/* Password Input Wrapper */
.password-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.password-input-wrapper input {
  flex: 1;
  padding-right: 45px !important;
}

.password-toggle {
  position: absolute;
  right: 10px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 18px;
  padding: 5px 10px;
  line-height: 1;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.password-toggle:hover {
  opacity: 1;
}

/* Password Strength Indicator */
.password-strength {
  margin-top: 8px;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  transition: all 0.3s ease;
}

.password-strength.weak {
  background-color: rgba(239, 68, 68, 0.2);
  color: #ef4444;
  border: 1px solid #ef4444;
}

.password-strength.medium {
  background-color: rgba(251, 191, 36, 0.2);
  color: #fbbf24;
  border: 1px solid #fbbf24;
}

.password-strength.strong {
  background-color: rgba(74, 222, 128, 0.2);
  color: #4ade80;
  border: 1px solid #4ade80;
}

/* Password Requirements */
.password-requirements {
  margin-top: 12px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 8px;
  border: 1px solid #333;
}

.password-requirements small {
  color: #888;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.password-requirements ul {
  margin: 8px 0 0 0;
  padding: 0 0 0 20px;
  list-style: none;
}

.password-requirements li {
  font-size: 13px;
  color: #888;
  margin: 4px 0;
  position: relative;
  transition: color 0.3s ease;
}

.password-requirements li::before {
  content: '○';
  position: absolute;
  left: -20px;
  transition: content 0.3s ease;
}

.password-requirements li[style*="color: rgb(74, 222, 128)"]::before,
.password-requirements li[style*="color:#4ade80"]::before {
  content: '✓';
}

/* Info Message */
.info-message {
  padding: 15px;
  background: rgba(0, 212, 255, 0.1);
  border: 1px solid rgba(0, 212, 255, 0.3);
  border-radius: 8px;
  color: #00D4FF;
  font-size: 14px;
  margin-bottom: 20px;
  line-height: 1.6;
}

/* Success Message */
.success-message {
  padding: 15px;
  background: rgba(74, 222, 128, 0.1);
  border: 1px solid rgba(74, 222, 128, 0.3);
  border-radius: 8px;
  color: #4ade80;
  font-size: 14px;
  margin-top: 15px;
  line-height: 1.6;
}

/* Hide when empty */
.success-message:empty {
  display: none;
}

/* Error Message */
.error-message {
  padding: 15px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 8px;
  color: #ef4444;
  font-size: 14px;
  margin-top: 15px;
  line-height: 1.6;
}

/* Hide when empty */
.error-message:empty {
  display: none;
}

/* ========================================
   SUBSCRIPTION MODAL STYLES
   ======================================== */

/* Modal Overlay */
.subscription-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}

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

.subscription-modal-content {
  background: var(--bg-card);
  border-radius: 16px;
  max-width: 900px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.3s ease;
}

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

.subscription-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.subscription-modal-header h2 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.close-modal-btn {
  background: none;
  border: none;
  font-size: 2rem;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.close-modal-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.subscription-tiers {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  padding: 24px;
}

.subscription-tier {
  background: var(--bg-dark);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 20px;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
}

.subscription-tier:hover {
  border-color: var(--color-primary);
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.tier-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.tier-icon {
  font-size: 2rem;
}

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

.tier-price {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: 8px;
}

.tier-credits {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.tier-features {
  list-style: none;
  padding: 0;
  margin: 0 0 20px 0;
  flex-grow: 1;
}

.tier-features li {
  padding: 8px 0;
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.subscribe-btn {
  width: 100%;
  padding: 14px 20px;
  background: var(--color-primary);
  color: var(--bg-dark);
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.subscribe-btn:hover {
  background: var(--color-primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(79, 195, 247, 0.3);
}

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

.subscribe-btn.recommended {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-accent) 100%);
}

.subscription-modal-footer {
  padding: 24px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  text-align: center;
}

.subscription-modal-footer p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin: 4px 0;
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.9);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10001;
}

.loading-content {
  text-align: center;
}

.loading-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 20px;
}

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

.loading-message {
  font-size: 1.1rem;
  color: var(--text-primary);
  font-weight: 500;
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .subscription-tiers {
    grid-template-columns: 1fr;
    padding: 16px;
  }

  .subscription-modal-header {
    padding: 16px;
  }

  .subscription-modal-header h2 {
    font-size: 1.25rem;
  }

  .subscription-modal-footer {
    padding: 16px;
  }

  .tier-price {
    font-size: 1.5rem;
  }
}

/* Subscription Status in Settings */
.subscription-section {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.subscription-active {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.subscription-active .status {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-success);
}

.subscription-active p {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin: 4px 0;
}

.subscription-active .note {
  font-size: 0.85rem;
  color: var(--text-secondary);
  opacity: 0.7;
  margin-top: 8px;
}

.byok-status {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.byok-status p {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin: 4px 0;
}

.byok-status h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 16px 0 8px 0;
}

.subscription-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
}

/* Modal Action Button Overrides - Fix for desktop */
.modal-actions .btn {
  width: auto !important;
  text-transform: none !important;
  letter-spacing: normal !important;
  font-size: 14px !important;
  padding: 10px 12px !important;
}

