/* styles.css file */

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

:root {
  /* Colors */
  --bg-main: #F8FAFC;
  --bg-card: #FFFFFF;
  --gradient-start: #6366F1;
  --gradient-end: #8B5CF6;
  --text-primary: #1E293B;
  --text-secondary: #64748B;
  --text-white: #FFFFFF;
  --border-light: #F1F5F9;
  --border-medium: #E2E8F0;
  --record-red: #EF4444;
  --record-red-hover: #DC2626;
  --stop-gray: #6B7280;
  --success-green: #22C55E;
  --warning-orange: #F97316;
  --error-red: #EF4444;
  
  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-xxl: 48px;
  
  /* Typography */
  --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  
  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);
}

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

/* Container */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0;
}

/* History Button */
.history-button {
  position: fixed;
  top: var(--space-md);
  right: var(--space-md);
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: 8px;
  padding: var(--space-sm) var(--space-md);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
  z-index: 100;
}

.history-button:hover {
  background: var(--bg-main);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

/* Header */
.header {
  background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
  color: var(--text-white);
  padding: var(--space-lg) var(--space-md);
  text-align: center;
  box-shadow: var(--shadow-md);
}

.header-logo {
  max-width: 280px;
  width: 70%;
  height: auto;
  margin-bottom: var(--space-xs);
}

.header p {
  font-size: 14px;
  opacity: 0.95;
}

/* Main Content */
.main-content {
  padding: var(--space-md);
}

/* Card Component */
.card {
  background: var(--bg-card);
  border-radius: 12px;
  padding: var(--space-md);
  margin-bottom: var(--space-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
}

/* Tips Sections */

.tips-section {
  background: var(--bg-card);
  border-radius: 12px;
  border: 1px solid var(--border-light);
  margin-bottom: var(--space-md);
  overflow: hidden;
  transition: all 0.2s ease;
}

.tips-header {
  padding: 6px var(--space-lg);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
  color: var(--text-white);
  font-weight: 600;
  font-size: 16px;
}

.tips-header:hover {
  background: linear-gradient(135deg, #5856eb, #7c3aed);
}
    
.tips-toggle {
  font-size: 14px;
  opacity: 0.9;
}

.tips-content {
  padding: 0;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, padding 0.3s ease;
}

.tips-content.expanded {
  padding: var(--space-lg);
  max-height: 500px;
}

.tips-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.tip-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--bg-main);
  border-radius: 8px;
  border: 1px solid var(--border-light);
}

.tip-icon {
  font-size: 20px;
  min-width: 24px;
  text-align: center;
}

.tip-content {
  flex: 1;
}

.tip-title {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: var(--space-xs);
  color: var(--text-primary);
}

.tip-description {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.tips-dismiss {
  text-align: center;
}

.dismiss-btn {
  background: var(--gradient-start);
  color: var(--text-white);
  border: none;
  border-radius: 6px;
  padding: var(--space-sm) var(--space-lg);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.dismiss-btn:hover {
  background: #5856eb;
  transform: translateY(-1px);
}

/* Mobile-specific vertical layout for settings */
@media (max-width: 767px) {
  .settings-mobile-vertical {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);  /* Changed from var(--space-md) for tighter spacing */
  }
  
  .setting-group-mobile {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
  }
  
  .setting-group-mobile .setting-label {
    margin-bottom: var(--space-xs);
  }
  
  .setting-group-mobile .tooltip-toggle-wrapper {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
  }
  
  /* Ensure the tolerance controls stay horizontal on mobile */
  .setting-group-mobile .tolerance-controls {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-top: 0;
  }
  
  /* Keep accent control compact and centered on mobile */
  .setting-group-mobile .accent-segmented-control {
    align-self: center;
  }
}

/* Hide mobile vertical layout on desktop */
@media (min-width: 768px) {
  .settings-mobile-vertical,
  .setting-group-mobile {
    display: none !important;
  }
}


/* Recording Section */
.recording-card {
  text-align: center;
}

.record-button {
  background: var(--record-red);
  color: var(--text-white);
  border: none;
  border-radius: 28px;
  padding: var(--space-md) var(--space-xl);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-md);
  min-width: 180px;
  height: 56px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.record-button:hover:not(:disabled) {
  background: var(--record-red-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

.record-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.record-button.stop {
  background: var(--stop-gray);
}

.record-button.stop:hover:not(:disabled) {
  background: #4B5563;
}

/* Waveform */
.waveform-container {
  margin-top: var(--space-md);
  padding: 0;
  background: transparent;
  border-radius: 0;
  display: none;
  position: relative;
}

.waveform-canvas {
  width: 100%;
  height: 30px;
  background: var(--text-primary);
  border-radius: 8px;
  display: block;
  opacity: 0.85;
}
.waveform-canvas.hidden {
  opacity: 0;
}

/* Spinner inside waveform container */
.waveform-spinner {
  display: none;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top: 3px solid var(--gradient-start);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  z-index: 10;
}

.waveform-spinner.active {
  display: block;
}

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

/* Feedback Section */
.feedback-card {
  min-height: 120px;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: var(--space-md);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.feedback-content {
  font-size: 18px;
  line-height: 1.8;
  color: var(--text-primary);
  min-height: 80px;
}

.toggle-view-btn {
  margin-top: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.toggle-view-btn:hover {
  background: var(--bg-main);
  border-color: var(--gradient-start);
  color: var(--gradient-start);
}

.placeholder {
  color: var(--text-secondary);
  font-style: italic;
  font-size: 1.2em;
  font-weight: 500;
  opacity: 0.8;
}

/* Stacked word display */
.stacked-display {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: var(--space-md);
  line-height: 1.4;
}


/* ============================================
PRONUNCIATION DISPLAY STYLES
All word display, color, and error styling
============================================ */

/* --- Stacked Word Container --- */
.stacked-word-container {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;                  /* ADJUST: Space between phonetic/transcribed */
  min-width: 0;
  position: relative;
}

.stacked-word-container.clickable {
  cursor: pointer;
  padding: var(--space-xs) var(--space-sm);
  border-radius: 8px;
  transition: all 0.2s ease;
}

.stacked-word-container.clickable:hover {
  background: rgba(0, 0, 0, 0.05);
  transform: scale(1.02);
}

.stacked-word-container.playing {
  background: rgba(255, 235, 59, 0.2);
}

/* --- Phonetic Word Display (Top) --- */
.phonetic-word {
  font-size: 24px;           /* Size of phonetic text */
  line-height: 1.2;
  font-weight: 500;
  white-space: nowrap;
}

/* --- Transcribed Word Display (Bottom) --- */
.transcribed-word {
  font-size: 24px;           /* Size of transcribed text */
  line-height: 1.2;
  color: #999999;       /* Default color for transcribed  ***/
  white-space: nowrap;
}

/* --- Word Score Display --- */
.word-score {
  font-size: 11px;
  font-weight: 600;
  margin-top: 2px;
  opacity: 0.9;
  color: #8c8bda;  /* Default color for passed scores ***/
}

.word-score.failed {
  color: #9e97f5;    /* Colour for failed/partorated states ***/
}

/* --- Word-Level Colors by Tolerance State --- */
span[data-tolerance-state="passed"],
span[data-tolerance-state="tolerated"] {
  color: #8c8bda;            /* Color for correct words ***/
}

span[data-tolerance-state="failed"],
span[data-tolerance-state="partorated"] {
  color: #4A3FE5;                /*  Color for error words ***/
}

span[data-tolerance-state="unknown"] {
  color: #555;
}

/* --- Letter-Level Error Styling --- */
.phoneme-error {
  color: #4A3FE5;                       /*  Error letter color ***/
  font-size: 100%;                      /*  Error letter size - relative */
  font-weight: 800;
/*  opacity: 0.7;                         /*  Error letter opacity */
  text-decoration: underline;
  text-underline-offset: 3px;           /*  Underline distance */
  cursor: help;
  position: relative;
  margin: 0 2px;             /* side margins */
}

.phoneme-tolerated {
  cursor: help;
  position: relative;
  border-bottom: 1px dashed #94A3B8;
}

/* Ensure tolerated letters in partorated/failed words inherit  */
span[data-tolerance-state="failed"] .phoneme-tolerated,
span[data-tolerance-state="partorated"] .phoneme-tolerated {
  color: inherit;
}

/* Ensure tolerated letters in tolerated/passed words inherit  */
span[data-tolerance-state="tolerated"] .phoneme-tolerated,
span[data-tolerance-state="passed"] .phoneme-tolerated {
  color: inherit;
}

/* --- Multi-letter Phoneme Groups --- */
.phoneme-digraph {
  display: inline-block;
  letter-spacing: -0.08em;   /* Digraph letter spacing */
  font-weight: 700;          /* Digraph letter weight */
  margin: 0 2px;             /* Digraph side margins */
}

/* --- Mobile Responsive Adjustments --- */
@media (max-width: 767px) {
  .phonetic-word, .transcribed-word {
    font-size: 16px;         /* Mobile font size */
  }
  
  .phonetic-word .phoneme-digraph {
    letter-spacing: -0.07em;    /* Digraph letter spacing */
  }
}

/* --- Desktop Responsive Adjustments --- */
@media (min-width: 768px) {
  .phonetic-word .phoneme-digraph {
    letter-spacing: -0.08em;    /* Digraph letter spacing */
  }
}

/* ============ End of Pronunciation Display Styles ===================== */

.stacked-display {
  gap: var(--space-sm);
}

/* Settings Section - Simplified for IPA toggle only */
.settings-card {
  display: block;
  padding: 12px var(--space-md) !important;
}

.settings-simple {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
}

.setting-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

/* Toggle Switch Styles */
.tooltip-controls {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.tooltip-toggle-wrapper {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

/* Two-toggle row layout for IPA settings */
.tooltip-toggle-row {
  display: flex;
  gap: var(--space-lg);
  align-items: center;
  flex-wrap: wrap;
}

.tooltip-toggle-row .tooltip-toggle-wrapper {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex: 0 1 auto;
}



.toggle-switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 19.5px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--border-medium);
  transition: 0.3s;
  border-radius: 19.5px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 15px;
  width: 15px;
  left: 2.25px;
  bottom: 2.25px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
  background-color: var(--gradient-start);
}

.toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(16.5px);
}  

.toggle-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  user-select: none;
}

  /* Settings Divider */
  .settings-divider {
    height: 1px;
    background: var(--border-medium);
    margin: var(--space-md) 0;
  }
  
   /* Tolerance Slider Styles */
  .tolerance-controls {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin: 0;
    align-self: center;
  }
  
  .slider-label-left,
  .slider-label-right {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    min-width: 50px;
  }
  
  .slider-label-left {
    text-align: right;
  }
  
  .slider-label-right {
    text-align: left;
  }
  
  .tolerance-slider {
    flex: 1;
    height: 4.5px;
    background: var(--border-medium);
    border-radius: 2.25px;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
  }
  
  .tolerance-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: var(--gradient-start);
    cursor: pointer;
    transition: all 0.2s ease;
  }
  
  .tolerance-slider::-moz-range-thumb {
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: var(--gradient-start);
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
  }
  
  .tolerance-slider:hover::-webkit-slider-thumb {
    transform: scale(1.1);
    background: #5856eb;
  }
  
  .tolerance-slider:hover::-moz-range-thumb {
    transform: scale(1.1);
    background: #5856eb;
  }
  
  /* Mobile specific adjustments for tolerance */
  @media (max-width: 767px) {
    .tolerance-controls {
      gap: var(--space-sm);
    }
    
    .slider-label-left,
    .slider-label-right {
      min-width: 45px;
      font-size: 12px;
    }
  }

  /* Mobile-specific smaller toggle */
  @media (max-width: 767px) {
  .toggle-switch {
    width: 30px;  /* 25% reduction from 40px */
    height: 16.5px;  /* 25% reduction from 22px */
  }
  
  .toggle-slider:before {
    height: 12px;  /* 25% reduction from 16px */
    width: 12px;   /* 25% reduction from 16px */
    left: 2.25px;
    bottom: 2.25px;
  }
  
  .toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(13.5px);  /* 25% reduction from 18px */
  }
  
  .toggle-label {
    font-size: 13px;  /* slightly smaller text */
  }

 .tooltip-toggle-row {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-md);
  }
  
  .tooltip-toggle-row .tooltip-toggle-wrapper {
    width: 100%;
  }
}

/* ============================================
   INFO TOOLTIPS FOR SETTINGS
   ============================================ */

/* Desktop: label is hoverable */
.label-with-info {
  position: relative;
  cursor: help;
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
}

.info-icon {
  font-size: 0.85em;
  opacity: 0.5;
  transition: opacity 0.2s ease;
}

.label-with-info:hover .info-icon {
  opacity: 0.8;
}

/* Desktop tooltip (JS-generated) */
.info-tooltip {
  position: absolute;
  background: #333;
  color: #fff;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: normal;
  line-height: 1.4;
  white-space: normal;
  max-width: 250px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  z-index: 1000;
  pointer-events: none;
  animation: tooltipFadeIn 0.15s ease;
}

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

/* Mobile: tap icon for popup */
.info-icon-mobile {
  display: none;
  font-size: 0.9em;
  opacity: 0.6;
  cursor: pointer;
  padding: 2px 6px;
  margin-left: 4px;
}

.info-icon-mobile:active {
  opacity: 1;
}

/* Mobile popup overlay */
.info-popup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 20px;
}

.info-popup {
  background: var(--card-bg, #fff);
  color: var(--text-primary, #333);
  padding: 20px;
  border-radius: 12px;
  max-width: 300px;
  text-align: center;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  animation: popupFadeIn 0.2s ease;
}

@keyframes popupFadeIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.info-popup p {
  margin: 0 0 15px 0;
  font-size: 0.95rem;
  line-height: 1.5;
}

.info-popup-close {
  background: var(--primary-color, #007bff);
  color: white;
  border: none;
  padding: 8px 24px;
  border-radius: 6px;
  font-size: 0.9rem;
  cursor: pointer;
}

/* Mobile breakpoint */
@media (max-width: 768px) {
  .label-with-info {
    cursor: default;
  }
  
  .label-with-info .info-icon {
    display: none;
  }
  
  .info-icon-mobile {
    display: inline;
  }
}


/* Segmented Control for Accent Selection */
  .accent-segmented-control {
    display: inline-flex;
    background: var(--bg-main);
    border: 1px solid var(--border-medium);
    border-radius: 8px;
    padding: 3px;
    gap: 2px;
  }

.accent-segment {
  padding: 3px 16px;
  font-size: 14px;
  font-weight: 500;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
  white-space: nowrap;
}

.accent-segment:hover {
  background: rgba(99, 102, 241, 0.1);
  color: var(--text-primary);
}

.accent-segment.active {
  background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
  color: var(--text-white);
  box-shadow: 0 2px 4px rgba(99, 102, 241, 0.2);
}

/* Quick Action Menu for Mobile */
.quick-action-menu {
  position: absolute;
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  padding: var(--space-xs);
  z-index: 1001;
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  min-width: 140px;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.quick-action-menu.show {
  opacity: 1;
  visibility: visible;
}

.quick-action-menu::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--bg-card);
}

.quick-action-btn {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border: none;
  background: var(--bg-card);
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.2s ease;
  text-align: left;
  width: 100%;
}

.quick-action-btn:hover {
  background: var(--bg-main);
}

.quick-action-btn:active {
  background: var(--border-light);
}

.quick-action-icon {
  font-size: 18px;
  min-width: 20px;
  text-align: center;
}

/* Overlay to catch outside clicks */
.quick-action-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  display: none;
}

.quick-action-overlay.show {
  display: block;
}

/* Session History Styles */
.history-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-md);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  overflow-y: auto;
}

.history-modal.show {
  opacity: 1;
  visibility: visible;
}

.history-container {
  background: var(--bg-card);
  border-radius: 16px;
  padding: var(--space-lg);
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  margin: auto;
}

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

.history-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
}

.history-close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.2s ease;
}

.history-close:hover {
  background: var(--bg-main);
}

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

.history-empty {
  text-align: center;
  padding: var(--space-xl);
  color: var(--text-secondary);
  font-style: italic;
}

.session-item {
  background: var(--bg-main);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: var(--space-md);
  cursor: pointer;
  transition: all 0.2s ease;
}

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

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

.session-date {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.session-score {
  font-size: 18px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.05);
}

.session-score.good {
  color: var(--success-green);
}

.session-score.medium {
  color: var(--warning-orange);
}

.session-score.poor {
  color: var(--error-red);
}

.session-text {
  font-size: 16px;
  color: var(--text-primary);
  margin-bottom: var(--space-xs);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-details {
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  gap: var(--space-md);
}

.session-actions {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-sm);
  padding-top: var(--space-sm);
  border-top: 1px solid var(--border-light);
}

.session-action-btn {
  flex: 1;
  padding: var(--space-xs) var(--space-sm);
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.session-action-btn:hover {
  background: var(--gradient-start);
  color: var(--text-white);
  border-color: var(--gradient-start);
}

.session-action-btn.delete {
  background: rgba(239, 68, 68, 0.1);
  color: var(--error-red);
  border-color: rgba(239, 68, 68, 0.3);
}

.session-action-btn.delete:hover {
  background: var(--error-red);
  color: var(--text-white);
  border-color: var(--error-red);
}

.storage-info {
  margin-top: var(--space-md);
  padding-top: var(--space-md);
  border-top: 1px solid var(--border-light);
  font-size: 12px;
  color: var(--text-secondary);
  text-align: center;
}

/* Playback Section */
.playback-section {
  margin-top: var(--space-md);
}

.playback-toggle {
  width: 100%;
  padding: var(--space-md);
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-secondary);
  text-align: left;
  transition: background 0.2s ease;
}

.playback-toggle:hover {
  background: var(--bg-main);
}

.playback-content {
  display: none;
  padding: var(--space-md);
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  margin-top: var(--space-sm);
}

.playback-content.show {
  display: block;
}

.playback-content audio {
  width: 100%;
  border-radius: 4px;
}

/* Hidden Audio */
#hiddenAudio {
  display: none;
}

/* Clickable Words */
.clickable-word {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-sm) var(--space-md);
  margin: var(--space-xs);
  min-width: 48px;
  min-height: 48px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  font-weight: 500;
}

.clickable-word:hover {
  background: rgba(0, 0, 0, 0.05);
  transform: scale(1.02);
}

.clickable-word.playing {
  background: rgba(255, 235, 59, 0.2);
}

/* Tooltips */
.word-tooltip {
  position: absolute;
  bottom: calc(100% + 8px);  /* Position above the entire stacked container */
  left: 50%;
  transform: translateX(-50%);
  background: var(--text-primary);
  color: var(--text-white);
  padding: var(--space-sm) var(--space-md);
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 1000;
  box-shadow: var(--shadow-md);
}

.word-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-top-color: var(--text-primary);
}

/* Update the hover selector to work with stacked containers */
.stacked-word-container:hover .word-tooltip {
  opacity: 1;
}

.phoneme-tooltip-standalone {
  background: var(--text-primary);
  color: var(--text-white);
  padding: var(--space-sm) var(--space-md);
  padding-right: 36px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: normal;
  line-height: 1.5;
  box-shadow: var(--shadow-lg);
  min-width: 200px;
  text-align: center;
  white-space: nowrap;
  z-index: 9999;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='white' viewBox='0 0 16 16'%3E%3Cpath d='M11.536 14.01A8.473 8.473 0 0 0 14.026 8a8.473 8.473 0 0 0-2.49-6.01l-.708.707A7.476 7.476 0 0 1 13.025 8c0 2.071-.84 3.946-2.197 5.303l.708.707z'/%3E%3Cpath d='M10.121 12.596A6.48 6.48 0 0 0 12.025 8a6.48 6.48 0 0 0-1.904-4.596l-.707.707A5.483 5.483 0 0 1 11.025 8a5.483 5.483 0 0 1-1.61 3.89l.706.706z'/%3E%3Cpath d='M8.707 11.182A4.486 4.486 0 0 0 10.025 8a4.486 4.486 0 0 0-1.318-3.182L8 5.525A3.489 3.489 0 0 1 9.025 8 3.49 3.49 0 0 1 8 10.475l.707.707zM6.717 3.55A.5.5 0 0 1 7 4v8a.5.5 0 0 1-.812.39L3.825 10.5H1.5A.5.5 0 0 1 1 10V6a.5.5 0 0 1 .5-.5h2.325l2.363-1.89a.5.5 0 0 1 .529-.06z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 14px 14px;
}

/* Desktop Styles */
@media (min-width: 768px) {
  .history-button {
    top: var(--space-sm);
    right: var(--space-sm);
  }

  .header {
    padding: var(--space-xl) var(--space-lg);
  }
  
  .header-logo {
    max-width: 320px;
  }

  .header p {
    font-size: 16px;
  }
  
  .main-content {
    padding: var(--space-lg);
  }

  .card {
    border-radius: 16px;
    padding: var(--space-xl);
    margin-bottom: var(--space-lg);
  }

  .tips-section {
    border-radius: 16px;
    margin-bottom: var(--space-lg);
  }

  .tips-header {
    padding: 8px var(--space-lg);
    font-size: 18px;
  }

  .tips-content.expanded {
    padding: var(--space-xl);
  }

  .tips-grid {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: var(--space-lg);
  }

  .record-button {
    height: 48px;
    font-size: 18px;
    min-width: 200px;
  }

  .card-title {
    font-size: 18px;
  }

  .feedback-content {
    font-size: 20px;
  }

  /* Two-column layout for record and settings */
  .controls-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-lg);
    margin-bottom: var(--space-lg);
  }

  .settings-card {
    padding: var(--space-xl);
  }
}

@media (min-width: 1024px) {
  .container {
    padding: 0 var(--space-lg);
  }
}

/* Mobile specific */
@media (max-width: 767px) {
  .history-button {
    top: var(--space-sm);
    right: var(--space-sm);
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
  }
  
  /* Hide the "History" text on mobile, keep only emoji */
  .history-button .history-text {
    display: none;
  }
  
  .history-container {
    padding: var(--space-md);
  }

  .review-container {
    padding: var(--space-sm);
    gap: var(--space-sm);
    max-width: 90%;
  }

  .review-word-display {
    padding: var(--space-sm);
  }

  .review-word {
    font-size: 24px;
    letter-spacing: 0.1em;
  }

  .error-details {
    padding: var(--space-sm);
  }

  .error-details-letter {
    font-size: 18px;
    margin-bottom: var(--space-xs);
  }

  .pronunciation-row {
    font-size: 13px;
  }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
  .clickable-word {
    min-height: 52px;
    min-width: 52px;
  }

  .quick-action-menu {
    min-width: 160px;
  }

  .quick-action-btn {
    padding: var(--space-md);
    font-size: 15px;
    min-height: 44px;
  }
}

/* Feedback Button */
.feedback-button {
  position: fixed;
  bottom: var(--space-md);
  right: var(--space-md);
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: 8px;
  padding: var(--space-sm) var(--space-md);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
}

.feedback-button.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.feedback-button:hover {
  background: var(--bg-main);
  box-shadow: var(--shadow-md);
  color: var(--text-primary);
}

/* Feedback Modal */
.feedback-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.feedback-modal.show {
  opacity: 1;
  visibility: visible;
}

.feedback-container {
  background: var(--bg-card);
  border-radius: 16px;
  padding: var(--space-lg);
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}

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

.feedback-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.feedback-close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.2s ease;
}

.feedback-close:hover {
  background: var(--bg-main);
}

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

.feedback-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.feedback-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.feedback-textarea {
  width: 100%;
  min-height: 120px;
  padding: var(--space-sm);
  border: 1px solid var(--border-medium);
  border-radius: 8px;
  font-family: var(--font-family);
  font-size: 14px;
  resize: vertical;
  transition: border 0.2s ease;
}

.feedback-input {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: var(--bg-primary);
  color: var(--text-primary);
  box-sizing: border-box;
}

.feedback-input:focus {
  outline: none;
  border-color: var(--gradient-start);
}

.feedback-input::placeholder {
  color: var(--text-secondary);
  font-size: 13px;
}

.feedback-textarea:focus {
  outline: none;
  border-color: var(--gradient-start);
}

.feedback-checkbox-group {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm);
  background: var(--bg-main);
  border-radius: 8px;
  cursor: pointer;
}

.feedback-checkbox {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.feedback-checkbox-label {
  font-size: 14px;
  color: var(--text-primary);
  cursor: pointer;
  user-select: none;
  flex: 1;
}

.feedback-session-info {
  font-size: 12px;
  color: var(--text-secondary);
  padding: var(--space-sm);
  background: var(--bg-main);
  border-radius: 6px;
  margin-top: 0;
  align-self: center;
}

.feedback-actions {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-md);
}

.feedback-submit-btn {
  flex: 1;
  padding: var(--space-sm) var(--space-lg);
  background: var(--gradient-start);
  color: var(--text-white);
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.feedback-submit-btn:hover {
  background: #5856eb;
  transform: translateY(-1px);
}

.feedback-submit-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.feedback-cancel-btn {
  flex: 1;
  padding: var(--space-sm) var(--space-lg);
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-medium);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.feedback-cancel-btn:hover {
  background: var(--bg-main);
}

.feedback-notice {
  font-size: 11px;
  color: var(--text-secondary);
  text-align: center;
  margin-top: var(--space-sm);
}

/* Reprocess Button Styles */
.reprocess-button {
  padding: var(--space-sm) var(--space-lg);
  background: var(--gradient-start);
  color: var(--text-white);
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  width: 100%;
}

.reprocess-button:hover:not(:disabled) {
  background: #5856eb;
  transform: translateY(-1px);
}

.reprocess-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  background: var(--border-medium);
  color: var(--text-secondary);
}

.reprocess-button.processing {
  opacity: 0.7;
  cursor: wait;
}

/* ===========================================
   PRACTICE MODE STYLES
   =========================================== */

.practice-button {
  background: var(--bg-card);
  color: var(--gradient-start);
  border: 2px solid var(--gradient-start);
  border-radius: 28px;
  padding: 0 var(--space-md);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  height: 56px;
  min-width: 70px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.practice-button:hover:not(:disabled) {
  background: var(--gradient-start);
  color: var(--text-white);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.practice-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  background: var(--bg-card);
  color: var(--text-secondary);
  border-color: var(--border-medium);
}

.practice-button:disabled:hover {
  transform: none;
  box-shadow: none;
}

/* Container for record + practice buttons */
.recording-buttons-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
}

/* Practice Mode Container - replaces recording UI */
.practice-mode-container {
  display: none;
  flex-direction: column;
  gap: var(--space-md);
  padding: var(--space-md) 0;
}

.practice-mode-container.active {
  display: flex;
}

/* Hide normal recording UI when practice mode is active */
.recording-card.practice-active .recording-buttons-row,
.recording-card.practice-active .waveform-container,
.recording-card.practice-active .active-phrase-display {
  display: none;
}

.recording-card.practice-active .practice-mode-container {
  display: flex;
}

/* Practice Mode Header */
.practice-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--border-light);
}

.practice-title {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-primary);
}

.practice-back-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  padding: var(--space-xs) var(--space-sm);
  border-radius: 6px;
  transition: all 0.2s ease;
}

.practice-back-btn:hover {
  background: var(--bg-main);
  color: var(--text-primary);
}

/* Pause dot separator in practice phrases */
.pause-dot {
  color: var(--gradient-start);
  opacity: 0.7;
  font-size: 1em;
  margin: 0 1px;
  display: inline-block;
}

/* Accent Selection Grid */
.accent-selection-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-sm);
}

.accent-option-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  padding: var(--space-md);
  background: var(--bg-main);
  border: 2px solid var(--border-light);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.accent-option-btn:hover {
  border-color: var(--gradient-start);
  background: var(--bg-card);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.accent-option-btn .accent-flag {
  font-size: 28px;
}

.accent-option-btn .accent-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

/* Phrase Selection */
.phrase-selection-container {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

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

.phrase-option-btn {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--bg-main);
  border: 2px solid var(--border-light);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
  width: 100%;
}

.phrase-option-btn:hover {
  border-color: var(--gradient-start);
  background: var(--bg-card);
}

/* Radio Button Styling */
.phrase-radio {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-medium);
  border-radius: 50%;
  background: var(--bg-card);
  flex-shrink: 0;
  position: relative;
  transition: all 0.2s ease;
}

/* Inner dot (hidden by default) */
.phrase-radio::after {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--gradient-start);
  opacity: 0;
  transform: scale(0);
  transition: all 0.2s ease;
}

/* Hover state - show partial selection on desktop */
.phrase-option-btn:hover .phrase-radio {
  border-color: var(--gradient-start);
  background: rgba(99, 102, 241, 0.05);
}

.phrase-option-btn:hover .phrase-radio::after {
  opacity: 0.5;
  transform: scale(1);
}

/* Active/clicking state */
.phrase-option-btn:active .phrase-radio::after {
  opacity: 1;
  transform: scale(1);
}

.phrase-option-btn .phrase-text {
  font-size: 15px;
  color: var(--text-primary);
  line-height: 1.4;
}

.phrase-option-btn .phrase-tier {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-secondary);
  background: var(--border-light);
  padding: 2px 8px;
  border-radius: 10px;
  flex-shrink: 0;
}

/* Phrase Actions Row */
.phrase-actions-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: var(--space-sm);
  border-top: 1px solid var(--border-light);
}

.refresh-phrases-btn {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  background: none;
  border: 1px solid var(--border-medium);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  padding: var(--space-xs) var(--space-md);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.refresh-phrases-btn:hover {
  background: var(--bg-main);
  border-color: var(--gradient-start);
  color: var(--gradient-start);
}

/* Active Phrase Display - shown below Start Recording */
.active-phrase-display {
  display: none;
  margin-top: var(--space-md);
  padding: var(--space-md);
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.08), rgba(139, 92, 246, 0.08));
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: 10px;
  position: relative;
}

.active-phrase-display.visible {
  display: block;
}

.active-phrase-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-xs);
}

.active-phrase-flag {
  font-size: 16px;
}

.active-phrase-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--gradient-start);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: none;
}
.active-phrase-clear {
  position: absolute;
  top: var(--space-sm);
  right: var(--space-sm);
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  padding: 0;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease;
}

.active-phrase-clear:hover {
  background: rgba(0, 0, 0, 0.1);
  color: var(--text-primary);
}

.active-phrase-text {
  font-size: 17px;
  font-weight: 500;
  color: var(--text-primary);
  font-style: italic;
  line-height: 1.4;
}

/* Mobile adjustments for practice mode */
@media (max-width: 767px) {
  .practice-button {
    height: 48px;
    min-width: 60px;
    font-size: 13px;
    padding: 0 var(--space-sm);
  }

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

  .accent-option-btn {
    padding: var(--space-sm);
  }

  .accent-option-btn .accent-flag {
    font-size: 24px;
  }

  .accent-option-btn .accent-name {
    font-size: 12px;
  }

  .phrase-option-btn {
    padding: var(--space-sm);
  }

  .phrase-option-btn .phrase-text {
    font-size: 14px;
  }

  .phrase-option-btn .phrase-tier {
    display: none;
  }

  .phrase-radio {
    width: 24px;
    height: 24px;
  }
  
  .phrase-radio::after {
    width: 12px;
    height: 12px;
  }
  .active-phrase-text {
    font-size: 15px;
  }
}

/* Desktop adjustments */
@media (min-width: 768px) {
  .practice-button {
    height: 48px;
  }

  .practice-title {
    font-size: 17px;
  }
}


/* ============================================
   DEBUG PANEL STYLES (Side Panel)
   ============================================ */

.debug-button {
  right: calc(var(--space-md) + 100px) !important;
}

@media (max-width: 768px) {
  .debug-button {
    right: calc(var(--space-sm) + 90px) !important;
  }
}

/* Side Panel */
.debug-panel {
  position: fixed;
  top: 0;
  right: -520px;
  width: 520px;
  height: 100vh;
  background: var(--bg-card);
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  transition: right 0.3s ease;
}

.debug-panel.show {
  right: 0;
}

.debug-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.debug-title {
  margin: 0;
  font-size: 1.1rem;
  color: var(--text-primary);
}

.debug-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 0;
  line-height: 1;
}

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

/* Table */
.debug-table-wrapper {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.debug-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.debug-table thead {
  position: sticky;
  top: 0;
  background: var(--bg-card);
  z-index: 1;
}

/* Compact table columns */
.debug-table th,
.debug-table td {
  padding: 6px 4px;
  font-size: 11px;
}

.debug-session-row:hover {
  background: var(--bg-main);
}

.debug-session-row.highlighted {
  background: rgba(99, 102, 241, 0.1);
}

/* Cell styles */
.debug-cell-date {
  white-space: nowrap;
  font-size: 0.75rem;
}

.debug-cell-score {
  font-weight: 600;
}

.debug-cell-score.good { color: #22c55e; }
.debug-cell-score.medium { color: #eab308; }
.debug-cell-score.poor { color: #ef4444; }

.debug-cell-wds,
.debug-cell-dev,
.debug-cell-acc,
.debug-cell-tol,
.debug-cell-user {
  text-align: center;
  color: var(--text-secondary);
}

.debug-cell-user {
  font-family: monospace;
  font-size: 0.7rem;
}

.debug-cell-actions {
  white-space: nowrap;
}

.debug-action-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 4px;
  font-size: 0.9rem;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.debug-action-btn:hover {
  opacity: 1;
}

.debug-locked {
  opacity: 0.4;
  font-size: 0.9rem;
}

.debug-loading,
.debug-empty,
.debug-error {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
}

.debug-error {
  color: #ef4444;
}

/* Leniency Boost Control in Debug Panel */
.debug-leniency-control {
  display: flex;
  align-items: center;
  padding: 4px 8px;
  background: rgba(255, 193, 7, 0.15);
  border: 1px solid rgba(255, 193, 7, 0.3);
  border-radius: 6px;
}

.debug-leniency-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #ffc107;
  font-weight: 500;
  white-space: nowrap;
}

.debug-leniency-slider {
  width: 80px;
}

.debug-leniency-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  background: #ffc107;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.debug-leniency-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  background: #ffc107;
  border-radius: 50%;
  cursor: pointer;
  border: none;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.debug-leniency-value {
  min-width: 32px;
  font-size: 12px;
}

/* Load more button in debug panel */
.debug-load-more {
  text-align: center;
  padding: 12px !important;
}

.debug-load-more-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #aaa;
  padding: 8px 20px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s ease;
}

.debug-load-more-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.debug-load-more-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ============================================
   LOGS MODAL STYLES
   ============================================ */

.logs-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  z-index: 2500;
  display: flex;
  justify-content: center;
  align-items: center;
}

.logs-container {
  background: var(--bg-card);
  border-radius: 12px;
  width: 720px;
  max-width: 95%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.logs-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-light);
}

.logs-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-primary);
}

.logs-session-id {
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 0.7rem;
  color: var(--text-secondary);
  background: var(--bg-main);
  padding: 3px 8px;
  border-radius: 4px;
}

.logs-close {
  margin-left: auto;
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 0;
  line-height: 1;
}

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

.logs-content {
  flex: 1;
  overflow: auto;
  padding: 16px 18px;
  margin: 0;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 0.75rem;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-main);
  white-space: pre;
  overflow-x: auto;
}

/* Footer */
.debug-footer {
  padding: 10px 16px;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-secondary);
  border-top: 1px solid var(--border-light);
  flex-shrink: 0;
}
  
  /* ============================================
   PRIVACY CONSENT MODAL
   ============================================ */

  /* Privacy Settings Link */
  .privacy-settings-link {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    cursor: pointer;
    transition: color 0.2s ease;
  }
  
  .privacy-settings-link:hover {
    color: var(--gradient-start);
    text-decoration: underline;
  }

  .privacy-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 3000;
    display: none;
    justify-content: center;
    align-items: center;
    padding: 20px;
    overflow-y: auto;
  }
  
  .privacy-modal.show {
    display: flex;
  }
  
  .privacy-container {
    background: var(--bg-card);
    border-radius: 16px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
  }
  
  .privacy-header {
    padding: 24px 24px 16px 24px;
    border-bottom: 2px solid var(--border-light);
  }
  
  .privacy-title {
    margin: 0;
    font-size: 1.5rem;
    color: var(--text-primary);
    font-weight: 600;
  }
  
  .privacy-content {
    padding: 24px;
  }
  
  .privacy-summary {
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 20px;
    line-height: 1.6;
  }
  
  .privacy-brief {
    background: var(--bg-main);
    padding: 16px;
    border-radius: 8px;
    border-left: 4px solid var(--gradient-start);
    margin-bottom: 20px;
  }
  
  .privacy-brief p {
    margin: 0 0 12px 0;
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.5;
  }
  
  .privacy-brief p:last-child {
    margin-bottom: 0;
  }
  
  /* Learn More Expandable Section */
  .privacy-details {
    margin-bottom: 24px;
  }
  
  .privacy-learn-more {
    width: 100%;
    background: transparent;
    border: 1px solid var(--border-medium);
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--gradient-start);
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
  }
  
  .privacy-learn-more:hover {
    background: rgba(99, 102, 241, 0.05);
    border-color: var(--gradient-start);
  }
  
  #privacyLearnMoreIcon {
    transition: transform 0.3s ease;
    font-size: 0.8rem;
  }
  
  .privacy-learn-more.expanded #privacyLearnMoreIcon {
    transform: rotate(180deg);
  }
  
  .privacy-details-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease, padding 0.4s ease;
    padding: 0 16px;
  }
  
  .privacy-details-content.expanded {
    max-height: 800px;
    padding: 20px 16px 0 16px;
  }
  
  .privacy-details-content h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 16px 0 12px 0;
  }
  
  .privacy-details-content h3:first-child {
    margin-top: 0;
  }
  
  .privacy-details-content p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 0 0 16px 0;
  }
  
  .privacy-details-content ul {
    list-style: none;
    padding: 0;
    margin: 0 0 16px 0;
  }
  
  .privacy-details-content ul li {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.8;
    padding-left: 0;
  }
  
  .privacy-contact {
    background: var(--bg-main);
    padding: 12px;
    border-radius: 6px;
    margin-top: 16px !important;
  }
  
  .privacy-details-content a {
    color: var(--gradient-start);
    text-decoration: none;
  }
  
  .privacy-details-content a:hover {
    text-decoration: underline;
  }
  
  /* Consent Checkbox */
  .privacy-consent-row {
    margin-bottom: 24px;
  }
  
  .privacy-checkbox-wrapper {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    cursor: pointer;
    padding: 16px;
    background: var(--bg-main);
    border-radius: 8px;
    border: 2px solid transparent;
    transition: all 0.2s ease;
  }
  
  .privacy-checkbox-wrapper:hover {
    border-color: var(--border-medium);
  }
  
  .privacy-checkbox-wrapper input[type="checkbox"] {
    margin-top: 2px;
    width: 20px;
    height: 20px;
    cursor: pointer;
    flex-shrink: 0;
  }
  
  .privacy-checkbox-label {
    font-size: 0.95rem;
    color: var(--text-primary);
    line-height: 1.5;
  }
  
  /* Action Buttons */
  .privacy-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
  }
  
  .privacy-btn {
    padding: 12px 32px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
  }
  
  .privacy-btn-primary {
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    color: var(--text-white);
  }
  
  .privacy-btn-primary:hover {
    background: linear-gradient(135deg, #5856eb, #7c3aed);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
  }

/* Mobile Responsive */
@media (max-width: 768px) {
  .privacy-container {
    max-height: 95vh;
  }
  
  .privacy-header {
    padding: 20px 20px 12px 20px;
  }
  
  .privacy-title {
    font-size: 1.25rem;
  }
  
  .privacy-content {
    padding: 20px;
  }
  
  .privacy-details-content.expanded {
    max-height: 1000px;
  }
  
  .privacy-btn {
    padding: 12px 24px;
    font-size: 0.95rem;
  }
}

/* Rate Limit Messages */
.rate-limit-message {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 14px;
  animation: slideIn 0.3s ease;
}

.rate-limit-message.warning {
  background: #fff3cd;
  border: 1px solid #ffc107;
  color: #856404;
}

.rate-limit-message.blocked {
  background: #f8d7da;
  border: 1px solid #f5c6cb;
  color: #721c24;
}

.rate-limit-icon {
  font-size: 18px;
}

.rate-limit-text {
  flex: 1;
}

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

.placeholder.error {
  color: #dc3545;
}

/* ============================================
   SPACING WARNING BANNER (Post-recording tip)
   ============================================ */

.spacing-warning-banner {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(139, 92, 246, 0.1));
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 10px;
  padding: 14px 18px;
  margin-top: var(--space-md);
  animation: slideIn 0.3s ease;
}

.spacing-warning-content {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.spacing-warning-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
}

.spacing-warning-text {
  flex: 1;
  font-size: 0.95rem;
  color: var(--text-primary);
  line-height: 1.4;
  min-width: 200px;
}

.spacing-warning-text strong {
  color: var(--gradient-start);
}

.spacing-warning-dismiss {
  background: var(--gradient-start);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 8px 16px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.spacing-warning-dismiss:hover {
  background: var(--gradient-end);
  transform: translateY(-1px);
}

@media (max-width: 480px) {
  .spacing-warning-content {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  
  .spacing-warning-dismiss {
    align-self: flex-end;
  }
}

