/* ==========================================================================
   Material Design 3 (M3) Design System — WebScribe
   ========================================================================== */

:root {
  /* M3 Seed Accent */
  --md-sys-color-primary: #a8c7fa;
  --md-sys-color-on-primary: #042a59;
  --md-sys-color-primary-container: #0842a0;
  --md-sys-color-on-primary-container: #d3e3fd;

  --md-sys-color-secondary: #7fcfff;
  --md-sys-color-on-secondary: #003355;
  --md-sys-color-secondary-container: #004a77;
  --md-sys-color-on-secondary-container: #c2e7ff;

  --md-sys-color-tertiary: #6dd58c;
  --md-sys-color-on-tertiary: #0a3818;
  --md-sys-color-tertiary-container: #0f5224;
  --md-sys-color-on-tertiary-container: #c4eed0;

  --md-sys-color-error: #ffb4ab;
  --md-sys-color-on-error: #690005;
  --md-sys-color-error-container: #93000a;
  --md-sys-color-on-error-container: #ffdad6;

  /* M3 Surface Container Roles (Dark Mode Standard) */
  --md-sys-color-surface: #111318;
  --md-sys-color-on-surface: #e2e2e9;
  --md-sys-color-surface-variant: #44474f;
  --md-sys-color-on-surface-variant: #c4c7cf;

  --md-sys-color-surface-container-lowest: #0c0e13;
  --md-sys-color-surface-container-low: #191c20;
  --md-sys-color-surface-container: #1d2024;
  --md-sys-color-surface-container-high: #272a2f;
  --md-sys-color-surface-container-highest: #32353a;

  --md-sys-color-outline: #8e9199;
  --md-sys-color-outline-variant: #44474f;

  /* Backward Compatibility Variables */
  --bg-color: var(--md-sys-color-surface);
  --card-bg: var(--md-sys-color-surface-container);
  --border-color: var(--md-sys-color-outline-variant);
  --text-color: var(--md-sys-color-on-surface);

  /* M3 Shape Scale */
  --md-sys-shape-none: 0px;
  --md-sys-shape-extra-small: 4px;
  --md-sys-shape-small: 8px;
  --md-sys-shape-medium: 12px;
  --md-sys-shape-large: 16px;
  --md-sys-shape-extra-large: 28px;
  --md-sys-shape-full: 9999px;

  /* M3 Elevation Scale */
  --md-sys-elevation-0: none;
  --md-sys-elevation-1: 0 1px 3px 1px rgba(0, 0, 0, 0.20), 0 1px 2px 0 rgba(0, 0, 0, 0.35);
  --md-sys-elevation-2: 0 2px 6px 2px rgba(0, 0, 0, 0.25), 0 1px 2px 0 rgba(0, 0, 0, 0.40);
  --md-sys-elevation-3: 0 4px 8px 3px rgba(0, 0, 0, 0.30), 0 1px 3px 0 rgba(0, 0, 0, 0.45);
  --md-sys-elevation-4: 0 6px 10px 4px rgba(0, 0, 0, 0.35), 0 2px 3px 0 rgba(0, 0, 0, 0.50);
  --md-sys-elevation-5: 0 8px 12px 6px rgba(0, 0, 0, 0.40), 0 4px 4px 0 rgba(0, 0, 0, 0.55);

  /* Typography */
  --font-family-base: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-family-code: "Cascadia Code", "Fira Code", "JetBrains Mono", Menlo, Consolas, monospace;
}

/* Base Document Reset */
* {
  box-sizing: border-box;
}

body {
  background-color: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  font-family: var(--font-family-base);
  min-height: 100vh;
  margin: 0;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ==========================================================================
   M3 App Scaffold & Layout
   ========================================================================== */

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

/* M3 Top App Bar */
.m3-top-app-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  padding: 0 20px;
  background-color: var(--md-sys-color-surface);
  border-bottom: 1px solid var(--md-sys-color-surface-container-highest);
  position: sticky;
  top: 0;
  z-index: 50;
  transition: background-color 200ms ease, box-shadow 200ms ease;
}

.m3-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
  user-select: none;
}

.m3-brand-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--md-sys-shape-medium);
  background: linear-gradient(135deg, var(--md-sys-color-primary-container) 0%, #152238 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--md-sys-color-primary);
  box-shadow: var(--md-sys-elevation-1);
}

.m3-brand-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
  color: var(--md-sys-color-on-surface);
  display: flex;
  align-items: center;
  gap: 8px;
}

.m3-top-app-bar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* M3 Top Bar Button Group */
.m3-button-group {
  display: inline-flex;
  align-items: center;
  background-color: var(--md-sys-color-surface-container-high);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-full);
  padding: 3px;
  gap: 4px;
}

.m3-button-group .badge {
  margin: 0 4px;
}

.m3-button-group #engineBadge {
  margin: 0 6px 0 8px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--md-sys-shape-full);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.m3-button-group .info-expandable-btn {
  border: none !important;
  background: transparent !important;
  width: 34px !important;
  height: 34px !important;
  min-width: 34px !important;
  padding: 0 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  border-radius: var(--md-sys-shape-full) !important;
  color: var(--md-sys-color-on-surface-variant) !important;
  cursor: pointer;
}
.m3-button-group .info-expandable-btn:hover {
  background-color: var(--md-sys-color-surface-container-highest) !important;
  color: var(--md-sys-color-primary) !important;
}
.m3-button-group .info-expandable-btn.is-loading {
  background-color: rgba(255, 193, 7, 0.12) !important;
}

.m3-button-group #pwaBtn {
  border: none !important;
  background: transparent !important;
  width: 34px !important;
  height: 34px !important;
  min-width: 34px !important;
  padding: 0 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  border-radius: var(--md-sys-shape-full) !important;
  color: var(--md-sys-color-on-surface-variant) !important;
  box-shadow: none !important;
}
.m3-button-group #pwaBtn:hover {
  background-color: var(--md-sys-color-surface-container-highest) !important;
  color: var(--md-sys-color-primary) !important;
}

/* Standalone Icon Button (Settings) */
.m3-icon-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--md-sys-shape-full);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: var(--md-sys-color-surface-container-high);
  border: 1px solid var(--md-sys-color-outline-variant);
  color: var(--md-sys-color-on-surface-variant);
  cursor: pointer;
  transition: all 150ms ease;
  padding: 0;
  box-sizing: border-box;
}
.m3-icon-btn:hover {
  background-color: var(--md-sys-color-surface-container-highest);
  border-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-primary);
}

/* Main Container */
.main-container,
.m3-main-container {
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  padding: 20px 16px 36px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1;
}

/* ==========================================================================
   M3 Cards & Containment
   ========================================================================== */

.card,
.m3-card {
  background-color: var(--md-sys-color-surface-container);
  border: 1px solid var(--md-sys-color-surface-container-highest);
  border-radius: var(--md-sys-shape-large);
  box-shadow: var(--md-sys-elevation-1);
  overflow: hidden;
  transition: box-shadow 200ms ease, border-color 200ms ease, transform 200ms ease;
}

.card:hover,
.m3-card:hover {
  box-shadow: var(--md-sys-elevation-2);
}

/* ==========================================================================
   Microphone, Waveform & Visualizer Assembly
   ========================================================================== */

.mic-panel-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 130px;
  padding: 1.5rem 1.25rem;
}

/* Microphone Permission Row */
#micRow {
  background-color: var(--md-sys-color-surface-container-high);
  border-radius: var(--md-sys-shape-medium) !important;
  border: 1px solid rgba(255, 193, 7, 0.25) !important;
  padding: 10px 14px;
}

.mic-waveform-wrapper {
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  padding: 0 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.waveform-container {
  position: relative;
  height: 60px;
  display: flex;
  align-items: center;
  flex: 1 1 0px !important;
  width: 0;
  min-width: 0;
}

.waveform-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* M3 Floating / Center Microphone Action Button */
.mic-btn,
.mic-btn.btn-primary {
  width: 72px !important;
  height: 72px !important;
  min-width: 72px !important;
  min-height: 72px !important;
  max-width: 72px !important;
  max-height: 72px !important;
  flex: 0 0 72px !important;
  border-radius: var(--md-sys-shape-full) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 0 !important;
  margin: 0 16px !important;
  color: #ffffff !important;
  outline: none !important;
  transform: none !important;
  cursor: pointer;
  position: relative;
  z-index: 2;
  flex-shrink: 0 !important;
  box-sizing: border-box !important;
  transition: background 0.2s ease,
              border-color 0.2s ease,
              box-shadow 0.2s ease;
}

/* ==========================================================================
   IDLE STATE (NOT recording): Flat Frosted Glass
   ========================================================================== */

.mic-btn:not(.recording),
.mic-btn.btn-primary:not(.recording) {
  background: rgba(255, 255, 255, 0.08) !important;
  backdrop-filter: blur(12px) saturate(180%);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.16) !important;
  box-shadow: none !important;
}

.mic-btn-icon-wrapper {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 100% !important;
  height: 100% !important;
  color: #ffffff !important;
  transform: none !important;
}

.mic-svg {
  width: 28px !important;
  height: 28px !important;
  min-width: 28px !important;
  min-height: 28px !important;
  max-width: 28px !important;
  max-height: 28px !important;
  display: block !important;
  fill: #ffffff !important;
  color: #ffffff !important;
  flex-shrink: 0 !important;
  transform: none !important;
  transition: none !important;
}

.mic-btn:not(.recording):hover:not(:disabled),
.mic-btn.btn-primary:not(.recording):hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.14) !important;
  border-color: rgba(255, 255, 255, 0.32) !important;
  box-shadow: none !important;
  transform: none !important;
  color: #ffffff !important;
}

.mic-btn:not(.recording):active:not(:disabled),
.mic-btn.btn-primary:not(.recording):active:not(:disabled) {
  background: rgba(255, 255, 255, 0.20) !important;
  border-color: rgba(255, 255, 255, 0.40) !important;
  transform: none !important;
  box-shadow: none !important;
}

.mic-btn:not(.recording):focus-visible {
  outline: 2px solid var(--md-sys-color-primary) !important;
  outline-offset: 3px;
  transform: none !important;
}

.mic-btn:not(.recording):disabled,
.mic-btn.btn-primary:not(.recording):disabled {
  opacity: 0.4 !important;
  background: rgba(255, 255, 255, 0.04) !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  cursor: not-allowed !important;
  box-shadow: none !important;
  transform: none !important;
}

/* ==========================================================================
   ACTIVE DICTATION STATE: ALWAYS GLOWING RED UNTIL STOPPED
   ========================================================================== */

.mic-btn.recording,
.mic-btn.btn-danger {
  color: #ffffff !important;
  backdrop-filter: blur(12px) saturate(180%);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  background-color: rgba(220, 20, 60, 0.82) !important;
  border: 1.5px solid rgba(255, 120, 140, 0.90) !important;
  box-shadow: 0 0 20px rgba(230, 25, 60, 0.85), 0 0 8px rgba(255, 107, 130, 0.60) !important;
  animation: m3MicPulse 2.0s ease-in-out infinite alternate !important;
  transform: none !important;
  opacity: 1 !important;
}

/* Always maintain red glow on hover while recording */
.mic-btn.recording:hover,
.mic-btn.btn-danger:hover {
  background-color: rgba(240, 30, 70, 0.92) !important;
  border-color: rgba(255, 150, 170, 1.0) !important;
  box-shadow: 0 0 32px rgba(230, 25, 60, 1.0), 0 0 14px rgba(255, 120, 140, 0.85) !important;
  transform: none !important;
  color: #ffffff !important;
}

/* Always maintain red glow on active/touch while recording */
.mic-btn.recording:active,
.mic-btn.btn-danger:active {
  background-color: rgba(195, 15, 50, 0.92) !important;
  border-color: rgba(255, 120, 140, 0.90) !important;
  box-shadow: 0 0 18px rgba(230, 25, 60, 0.85), 0 0 8px rgba(255, 107, 130, 0.60) !important;
  transform: none !important;
}

/* Maintain red glow when disabled during starting / stopping transitions */
.mic-btn.recording:disabled,
.mic-btn.btn-danger:disabled {
  opacity: 0.92 !important;
  cursor: wait !important;
  background-color: rgba(210, 20, 55, 0.78) !important;
  border-color: rgba(255, 110, 130, 0.80) !important;
  box-shadow: 0 0 20px rgba(230, 25, 60, 0.80), 0 0 8px rgba(255, 107, 130, 0.50) !important;
  transform: none !important;
}

@keyframes m3MicPulse {
  0% {
    background-color: rgba(185, 16, 45, 0.72);
    border-color: rgba(255, 107, 130, 0.75);
    box-shadow: 0 0 14px rgba(220, 20, 60, 0.75), 0 0 5px rgba(255, 107, 130, 0.55);
  }
  100% {
    background-color: rgba(238, 30, 68, 0.92);
    border-color: rgba(255, 150, 170, 0.98);
    box-shadow: 0 0 36px rgba(230, 25, 60, 0.98), 0 0 18px rgba(255, 140, 160, 0.80), 0 0 6px rgba(255, 255, 255, 0.5);
  }
}

/* ==========================================================================
   Transcript & Textarea Workspace
   ========================================================================== */

.m3-transcript-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

textarea#transcript {
  background-color: var(--md-sys-color-surface-container-lowest);
  color: var(--md-sys-color-on-surface);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-medium);
  padding: 16px;
  font-size: 15px;
  line-height: 1.6;
  font-family: var(--font-family-code);
  resize: vertical;
  height: 48vh;
  min-height: 230px;
  width: 100%;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

textarea#transcript:focus {
  outline: none;
  border-color: var(--md-sys-color-primary);
  box-shadow: 0 0 0 3px rgba(168, 199, 250, 0.2);
}

textarea#transcript[readonly] {
  background-color: rgba(12, 14, 19, 0.6);
  opacity: 0.85;
}

/* Custom Scrollbar for Textarea */
textarea#transcript::-webkit-scrollbar {
  width: 8px;
}
textarea#transcript::-webkit-scrollbar-track {
  background: var(--md-sys-color-surface-container-lowest);
  border-radius: var(--md-sys-shape-full);
}
textarea#transcript::-webkit-scrollbar-thumb {
  background-color: var(--md-sys-color-surface-container-highest);
  border-radius: var(--md-sys-shape-full);
  border: 2px solid var(--md-sys-color-surface-container-lowest);
}
textarea#transcript::-webkit-scrollbar-thumb:hover {
  background-color: var(--md-sys-color-outline);
}

/* Transcript Workspace Actions Bar */
.m3-workspace-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 4px;
  flex-wrap: wrap;
  gap: 8px;
}

#charCount {
  font-size: 13px;
  color: var(--md-sys-color-outline);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

/* ==========================================================================
   M3 Buttons & Chips
   ========================================================================== */

/* Primary / Filled Button (e.g., Copy & Clear) */
.btn-primary,
#copyClearBtn {
  background-color: var(--md-sys-color-primary) !important;
  color: var(--md-sys-color-on-primary) !important;
  border: none !important;
  border-radius: var(--md-sys-shape-full) !important;
  font-weight: 600 !important;
  font-size: 14px !important;
  padding: 0 24px !important;
  height: 40px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 8px !important;
  box-shadow: var(--md-sys-elevation-1) !important;
  transition: all 150ms cubic-bezier(0.4, 0, 0.2, 1) !important;
  user-select: none !important;
}

.btn-primary:hover:not(:disabled),
#copyClearBtn:hover:not(:disabled) {
  filter: brightness(1.08) !important;
  box-shadow: var(--md-sys-elevation-2) !important;
  transform: translateY(-1px) !important;
}

.btn-primary:active:not(:disabled),
#copyClearBtn:active:not(:disabled) {
  transform: translateY(0) !important;
  box-shadow: var(--md-sys-elevation-1) !important;
}

.btn-primary:disabled,
#copyClearBtn:disabled {
  background-color: var(--md-sys-color-surface-container-high) !important;
  color: rgba(255, 255, 255, 0.35) !important;
  box-shadow: none !important;
  cursor: not-allowed !important;
  opacity: 0.65 !important;
}

/* Tonal / Outlined Secondary Action Buttons (Pop Out, Settings) */
.btn-outline-secondary,
.btn-secondary {
  background-color: var(--md-sys-color-surface-container-high) !important;
  color: var(--md-sys-color-on-surface) !important;
  border: 1px solid var(--md-sys-color-outline-variant) !important;
  border-radius: var(--md-sys-shape-full) !important;
  font-size: 13px !important;
  font-weight: 500 !important;
  height: 36px !important;
  padding: 0 16px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  transition: all 150ms ease !important;
}

.btn-outline-secondary:hover:not(:disabled),
.btn-secondary:hover:not(:disabled) {
  background-color: var(--md-sys-color-surface-container-highest) !important;
  border-color: var(--md-sys-color-primary) !important;
  color: var(--md-sys-color-primary) !important;
}

/* System Information Button */
.info-icon {
  font-size: 1.15rem;
  line-height: 1;
  color: var(--md-sys-color-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* M3 Status Badges & Chips */
.badge {
  font-weight: 500 !important;
  font-size: 12px !important;
  padding: 4px 10px !important;
  border-radius: var(--md-sys-shape-full) !important;
  letter-spacing: 0.02em;
}

.badge-connected,
.bg-success {
  background-color: var(--md-sys-color-tertiary-container) !important;
  color: var(--md-sys-color-on-tertiary-container) !important;
}

.badge-reconnecting,
.bg-warning {
  background-color: #5c3b00 !important;
  color: #ffdd99 !important;
}

.badge-error,
.bg-danger {
  background-color: var(--md-sys-color-error-container) !important;
  color: var(--md-sys-color-on-error-container) !important;
}

.bg-info {
  background-color: var(--md-sys-color-secondary-container) !important;
  color: var(--md-sys-color-on-secondary-container) !important;
}

.bg-secondary {
  background-color: var(--md-sys-color-surface-container-highest) !important;
  color: var(--md-sys-color-on-surface-variant) !important;
}

/* ==========================================================================
   M3 Dialogs & Modals
   ========================================================================== */

.modal-backdrop.show {
  opacity: 0.72;
  backdrop-filter: blur(6px);
}

.modal-content {
  background-color: var(--md-sys-color-surface-container-high) !important;
  border: 1px solid var(--md-sys-color-surface-container-highest) !important;
  border-radius: var(--md-sys-shape-extra-large) !important;
  box-shadow: var(--md-sys-elevation-4) !important;
  color: var(--md-sys-color-on-surface) !important;
  overflow: hidden;
}

.modal-header {
  border-bottom: 1px solid var(--md-sys-color-surface-container-highest) !important;
  padding: 1.25rem 1.5rem !important;
}

.modal-header .modal-title {
  font-size: 1.25rem !important;
  font-weight: 600 !important;
  color: var(--md-sys-color-on-surface) !important;
}

.modal-body {
  padding: 1.5rem !important;
}

.modal-footer {
  border-top: 1px solid var(--md-sys-color-surface-container-highest) !important;
  padding: 1rem 1.5rem !important;
}

/* ==========================================================================
   Terms of Service Modal (Hautemic Specification & M3 Alignment)
   ========================================================================== */

.terms-modal-dialog {
  max-width: 760px;
  width: 100%;
}

.terms-modal-card {
  border-radius: var(--md-sys-shape-extra-large, 28px) !important;
  background-color: var(--md-sys-color-surface-container-high, #272a2f) !important;
  color: var(--md-sys-color-on-surface, #e2e2e9) !important;
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.terms-modal-body {
  padding: 20px 24px !important;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.terms-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.terms-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.terms-section-icon {
  font-size: 14px;
  line-height: 1;
}

.terms-section-header h4 {
  font-size: 13px;
  font-weight: 700;
  color: var(--md-sys-color-on-surface, #ffffff);
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.terms-card {
  background-color: var(--md-sys-color-surface-container-lowest, #0c0e13);
  border: 1px solid var(--md-sys-color-surface-container-highest, #32353a);
  border-radius: var(--md-sys-shape-small, 8px);
  padding: 14px 16px;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.4);
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--md-sys-color-on-surface-variant, #c4c7cf);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.terms-card strong {
  color: #ffffff;
}

.terms-card p {
  margin-bottom: 0;
}

.terms-caps {
  font-size: 11px;
  letter-spacing: 0.04em;
  line-height: 1.5;
  color: #f1fa8c;
  font-family: var(--font-family-code, monospace);
}

.font-mono {
  font-family: var(--font-family-code, monospace);
}

.terms-modal-footer {
  padding: 12px 20px !important;
  background-color: var(--md-sys-color-surface-container, #1d2024) !important;
  display: flex;
  justify-content: flex-end;
  border-top: 1px solid var(--md-sys-color-surface-container-highest, #32353a) !important;
}

/* App Footer subtle link */
.m3-app-footer {
  margin-top: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.footer-terms-link {
  font-size: 12px;
  transition: color 150ms ease;
}

.footer-terms-link:hover {
  color: var(--md-sys-color-primary) !important;
}

/* Operating Mode Cards in Settings */
#browserModeCard,
#serverModeCard,
#audioPreferencesPanel {
  background-color: var(--md-sys-color-surface-container) !important;
  border: 1px solid var(--md-sys-color-surface-container-highest) !important;
  border-radius: var(--md-sys-shape-large) !important;
  padding: 1.25rem !important;
  transition: all 200ms ease;
}

/* Switch on Right Alignment */
.form-switch.m3-switch-right {
  padding-left: 0 !important;
  display: flex !important;
  align-items: center !important;
  margin: 0 !important;
}

.form-switch.m3-switch-right .form-check-input {
  margin-left: 0 !important;
  float: none !important;
  cursor: pointer;
}

#serverModeCard.border-info {
  border: 2px solid var(--md-sys-color-primary) !important;
  background-color: var(--md-sys-color-surface-container-high) !important;
  box-shadow: var(--md-sys-elevation-1) !important;
}

#browserModeCard.border-success {
  border: 1px solid var(--md-sys-color-surface-container-highest) !important;
  background-color: var(--md-sys-color-surface-container) !important;
  box-shadow: none !important;
}

/* Form Controls (Selects, Inputs) */
.form-select,
.form-control {
  background-color: var(--md-sys-color-surface-container-lowest) !important;
  border: 1px solid var(--md-sys-color-outline-variant) !important;
  border-radius: var(--md-sys-shape-small) !important;
  color: var(--md-sys-color-on-surface) !important;
  height: 42px;
  font-size: 14px;
}

.form-select:focus,
.form-control:focus {
  border-color: var(--md-sys-color-primary) !important;
  box-shadow: 0 0 0 3px rgba(168, 199, 250, 0.2) !important;
  outline: none;
}

/* M3 Switches */
.form-check-input {
  cursor: pointer;
}

.form-switch .form-check-input {
  width: 2.75em !important;
  height: 1.5em !important;
  background-color: var(--md-sys-color-surface-container-highest) !important;
  border-color: var(--md-sys-color-outline-variant) !important;
  border-radius: var(--md-sys-shape-full) !important;
  transition: background-position 0.15s ease-in-out, background-color 0.15s ease-in-out;
}

.form-switch .form-check-input:checked {
  background-color: var(--md-sys-color-primary) !important;
  border-color: var(--md-sys-color-primary) !important;
}

/* Linear Progress Bar (Model Downloads) */
.progress {
  background-color: var(--md-sys-color-surface-container-highest) !important;
  border-radius: var(--md-sys-shape-full) !important;
  overflow: hidden;
}

.progress-bar {
  background-color: var(--md-sys-color-primary) !important;
  border-radius: var(--md-sys-shape-full);
}

#loadBrowserModelBtn {
  height: 40px !important;
  border-radius: var(--md-sys-shape-full) !important;
}

#clearModelCacheBtn {
  height: 40px !important;
  border-radius: var(--md-sys-shape-full) !important;
  font-size: 13px !important;
  font-weight: 500 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  border: 1px solid var(--md-sys-color-error) !important;
  color: var(--md-sys-color-error) !important;
  background-color: transparent !important;
  transition: all 150ms ease !important;
}

#clearModelCacheBtn:hover {
  background-color: var(--md-sys-color-error-container) !important;
  color: var(--md-sys-color-on-error-container) !important;
}

#clearModelCacheBtn.d-none {
  display: none !important;
}

/* ==========================================================================
   M3 Toast / Snackbar
   ========================================================================== */

.toast-container {
  position: fixed !important;
  bottom: 24px !important;
  left: 50% !important;
  right: auto !important;
  transform: translateX(-50%) !important;
  z-index: 1050;
  padding: 0 !important;
  width: auto !important;
}

.toast {
  background-color: var(--md-sys-color-surface-container-highest) !important;
  color: var(--md-sys-color-on-surface) !important;
  border: 1px solid var(--md-sys-color-outline-variant) !important;
  border-radius: var(--md-sys-shape-small) !important;
  box-shadow: var(--md-sys-elevation-3) !important;
  font-size: 14px;
  font-weight: 500;
  min-width: 240px;
}

/* ==========================================================================
   Responsive Breakpoints & Window Size Classes
   ========================================================================== */

/* Compact Mode (< 600px, e.g. Narrow PWA Pop-out windows 360px-450px) */
@media (max-width: 599px) {
  .m3-top-app-bar {
    padding: 0 12px;
    height: 56px;
  }

  .m3-brand-title {
    font-size: 1.1rem;
  }

  .main-container,
  .m3-main-container {
    padding: 12px 10px 24px;
    gap: 12px;
  }

  .mic-panel-body {
    padding: 1rem 0.5rem;
  }

  .waveform-container {
    height: 48px;
  }

  textarea#transcript {
    padding: 12px;
    font-size: 14px;
    min-height: 200px;
  }
}
