/* ==========================================================================
   Teleprompter CSS Design System - Sleek Deep Space UI
   ========================================================================== */

/* --- Google Fonts Import --- */
@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500&family=Inter:wght@300;400;500;600;700&family=Playfair+Display:ital,wght@0,400;0,600;0,700;1,400&display=swap');

/* --- CSS Variables --- */
:root {
  /* Color Palette */
  --bg-main: #0a0d14;
  --bg-sidebar: #10141f;
  --bg-card: #161c2b;
  --bg-glass: rgba(16, 20, 31, 0.7);
  --bg-glass-active: rgba(22, 28, 43, 0.85);
  
  --border-color: rgba(255, 255, 255, 0.08);
  --border-color-hover: rgba(255, 255, 255, 0.16);
  --border-glow: rgba(79, 70, 229, 0.3);

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  /* Vibrant Accents */
  --accent-primary: #6366f1; /* Indigo */
  --accent-secondary: #06b6d4; /* Cyan */
  --accent-success: #10b981; /* Emerald */
  --accent-error: #ef4444; /* Rose */
  --accent-gradient: linear-gradient(135deg, #6366f1 0%, #06b6d4 100%);
  --accent-gradient-glow: linear-gradient(135deg, rgba(99, 102, 241, 0.5) 0%, rgba(6, 182, 212, 0.5) 100%);

  /* Typography Styles */
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-serif: 'Playfair Display', Georgia, serif;
  --font-mono: 'Fira Code', 'Courier New', monospace;
  
  /* Interface Constants */
  --border-radius-sm: 8px;
  --border-radius-md: 12px;
  --border-radius-lg: 20px;
  --transition-fast: 0.2s ease;
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.15);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 10px 10px -5px rgba(0, 0, 0, 0.3);
  --shadow-glow: 0 0 15px rgba(99, 102, 241, 0.25);
  
  /* Interactive Defaults */
  --sidebar-width: 320px;
  --prompter-margin-width: 700px;
}

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

body {
  background-color: var(--bg-main);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  overflow-x: hidden;
  min-height: 100vh;
  min-height: 100dvh;
}

body.legal-page {
  overflow: auto;
}

.legal-shell {
  width: min(760px, calc(100vw - 40px));
  margin: 0 auto;
  padding: 64px 0 80px;
}

.legal-back-link,
.legal-shell a {
  color: var(--accent-secondary);
}

.legal-back-link {
  display: inline-flex;
  margin-bottom: 36px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
}

.legal-back-link:hover {
  color: var(--accent-secondary);
}

.legal-shell h1 {
  margin-bottom: 36px;
  font-size: clamp(2.25rem, 8vw, 4rem);
  line-height: 1;
  color: var(--text-primary);
}

.legal-shell section {
  padding: 28px 0;
  border-top: 1px solid var(--border-color);
}

.legal-shell h2 {
  margin-bottom: 16px;
  font-size: 1.1rem;
  color: var(--text-primary);
}

.legal-shell h3 {
  margin: 22px 0 8px;
  font-size: 0.92rem;
  color: var(--text-secondary);
}

.legal-shell p,
.legal-shell address {
  max-width: 68ch;
  color: var(--text-secondary);
  font-style: normal;
}

.legal-shell p + p,
.legal-shell address + p {
  margin-top: 14px;
}

/* Custom Scrollbar Styles */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ==========================================================================
   Dashboard Layout & Components
   ========================================================================== */

#app-container {
  display: flex;
  height: 100vh;
  height: 100dvh;
  width: 100vw;
  position: relative;
  overflow: hidden;
}

/* --- View Toggle Logic --- */
.view-panel {
  display: flex;
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal), transform var(--transition-normal);
}

.view-panel.active {
  opacity: 1;
  pointer-events: auto;
}

#dashboard-view {
  transform: scale(1);
}

#dashboard-view.hidden {
  transform: scale(0.96);
}

#prompter-view {
  transform: translateY(20px);
  z-index: 100;
  background-color: #050608;
}

#prompter-view.active {
  transform: translateY(0);
}

/* --- Sidebar Panels --- */
.sidebar {
  width: var(--sidebar-width);
  height: 100%;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.brand {
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border-color);
}

.brand-logo {
  width: 32px;
  height: 32px;
  background: var(--accent-gradient);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-glow);
}

.brand-logo svg {
  width: 18px;
  height: 18px;
  fill: #fff;
}

.brand h1 {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* --- Sidebar Actions --- */
.sidebar-actions {
  padding: 20px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px 18px;
  border-radius: var(--border-radius-md);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
}

.btn-primary {
  background: var(--accent-gradient);
  color: #fff;
  box-shadow: var(--shadow-glow);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 22px rgba(99, 102, 241, 0.4);
}

.btn-primary:active {
  transform: translateY(1px);
}

.btn-secondary {
  background-color: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background-color: rgba(255, 255, 255, 0.05);
  border-color: var(--border-color-hover);
}

/* --- Scripts List --- */
.scripts-list-container {
  flex-grow: 1;
  overflow-y: auto;
  padding: 0 12px 20px 12px;
}

.sidebar-footer {
  padding: 14px 20px 18px;
  border-top: 1px solid var(--border-color);
}

.sidebar-footer a {
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  transition: color var(--transition-fast);
}

.sidebar-footer a:hover {
  color: var(--accent-secondary);
}

.scripts-list-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 1px;
  padding: 12px;
}

.script-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  margin-bottom: 4px;
  transition: all var(--transition-fast);
  background-color: transparent;
  border: 1px solid transparent;
}

.script-item:hover {
  background-color: rgba(255, 255, 255, 0.03);
}

.script-item.active {
  background-color: rgba(99, 102, 241, 0.08);
  border-color: rgba(99, 102, 241, 0.2);
}

.script-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow: hidden;
  flex-grow: 1;
}

.script-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.script-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  gap: 8px;
}

.btn-delete {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  opacity: 0;
  transition: all var(--transition-fast);
}

.script-item:hover .btn-delete,
.script-item.active .btn-delete {
  opacity: 1;
}

.btn-delete:hover {
  color: var(--accent-error);
  background-color: rgba(239, 68, 68, 0.1);
}

/* ==========================================================================
   Main Workspace: Script Editor & Controls
   ========================================================================== */

.workspace {
  flex-grow: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background-color: var(--bg-main);
}

.workspace-header {
  padding: 20px 32px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.script-title-input {
  background: transparent;
  border: none;
  font-family: var(--font-sans);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
  outline: none;
  width: 60%;
  border-bottom: 1px dashed transparent;
  transition: border var(--transition-fast);
}

.script-title-input:focus {
  border-bottom-color: var(--accent-primary);
}

.workspace-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

/* --- Split Panel Workspace --- */
.editor-grid {
  display: flex;
  flex-grow: 1;
  overflow: hidden;
  height: calc(100vh - 81px);
  height: calc(100dvh - 81px);
}

.editor-area {
  flex-grow: 1;
  height: 100%;
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  border-right: 1px solid var(--border-color);
  background-color: rgba(10, 13, 20, 0.4);
}

.script-textarea {
  flex-grow: 1;
  width: 100%;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-lg);
  padding: 24px;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 1.05rem;
  line-height: 1.6;
  outline: none;
  resize: none;
  transition: border var(--transition-fast), box-shadow var(--transition-fast);
}

.script-textarea:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.15);
}

.stats-bar {
  display: flex;
  gap: 24px;
  padding: 4px 8px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.stat-item span {
  font-weight: 600;
  color: var(--accent-secondary);
}

/* --- Resize Handle --- */
.config-resize-handle {
  width: 5px;
  height: 100%;
  flex-shrink: 0;
  cursor: col-resize;
  background: transparent;
  transition: background 0.15s;
  position: relative;
  z-index: 10;
}

.config-resize-handle:hover,
.config-resize-handle.dragging {
  background: var(--accent-primary);
}

/* --- Settings Configuration Panel --- */
.config-panel {
  width: 360px;
  min-width: 260px;
  max-width: 640px;
  height: 100%;
  background-color: var(--bg-sidebar);
  overflow-y: auto;
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  flex-shrink: 0;
}

.section-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 1px;
  margin-bottom: 12px;
}

.control-group {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.control-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.control-value {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent-secondary);
}

/* Dynamic Input Styling */
input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--bg-main);
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent-primary);
  cursor: pointer;
  transition: transform var(--transition-fast);
  box-shadow: 0 0 8px rgba(99, 102, 241, 0.4);
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

select {
  width: 100%;
  padding: 10px;
  border-radius: var(--border-radius-sm);
  background-color: var(--bg-main);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  outline: none;
  cursor: pointer;
}

/* Custom Toggle Switch */
.switch-container {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  cursor: pointer;
}

.switch-container .control-label {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding-right: 0;
  line-height: 1.3;
}

.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 22px;
  flex-shrink: 0;
}

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

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--bg-main);
  transition: .3s;
  border-radius: 22px;
  border: 1px solid var(--border-color);
}

.slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background-color: var(--text-secondary);
  transition: .3s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--accent-primary);
  border-color: var(--accent-primary);
}

input:checked + .slider:before {
  transform: translateX(22px);
  background-color: #fff;
}

.tooltip-help {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  border: 1px solid var(--border-color-hover);
  border-radius: 50%;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1;
  cursor: help;
  outline: none;
}

.tooltip-help:hover,
.tooltip-help:focus,
.tooltip-help:focus-visible,
.tooltip-help.is-visible {
  color: var(--text-primary);
  border-color: var(--accent-secondary);
  background: rgba(6, 182, 212, 0.12);
}

.tooltip-help::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  z-index: 50;
  width: max-content;
  max-width: 220px;
  transform: translate(-50%, 4px);
  padding: 8px 10px;
  border: 1px solid var(--border-color-hover);
  border-radius: var(--border-radius-sm);
  background: #0b0f18;
  color: var(--text-primary);
  box-shadow: var(--shadow-md);
  font-size: 0.74rem;
  font-weight: 600;
  line-height: 1.35;
  white-space: normal;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.tooltip-help::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: calc(100% + 5px);
  z-index: 51;
  width: 8px;
  height: 8px;
  transform: translate(-50%, 4px) rotate(45deg);
  background: #0b0f18;
  border-right: 1px solid var(--border-color-hover);
  border-bottom: 1px solid var(--border-color-hover);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.tooltip-help:hover::after,
.tooltip-help:hover::before,
.tooltip-help:focus::after,
.tooltip-help:focus::before,
.tooltip-help:focus-visible::after,
.tooltip-help:focus-visible::before,
.tooltip-help.is-visible::after,
.tooltip-help.is-visible::before {
  opacity: 1;
  transform: translate(-50%, 0);
}

.tooltip-help:hover::before,
.tooltip-help:focus::before,
.tooltip-help:focus-visible::before,
.tooltip-help.is-visible::before {
  transform: translate(-50%, 0) rotate(45deg);
}

/* ==========================================================================
   Immersive Prompter Screen Mode
   ========================================================================== */

#prompter-view {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  position: fixed;
  overflow: hidden;
}

/* --- The Scroll Container --- */
.prompter-scroll-viewport {
  width: 100%;
  height: 100%;
  overflow-y: auto;
  scroll-behavior: auto; /* High performance smooth scroll done via script */
  position: relative;
  scrollbar-width: none; /* Hide scrollbars in prompter mode */
  padding-top: 45vh; /* Standard starting position */
  padding-top: 45dvh;
  padding-bottom: 55vh; /* Safe bottom spacing */
  padding-bottom: 55dvh;
}

.prompter-scroll-viewport::-webkit-scrollbar {
  display: none; /* Hide chrome/safari scrollbar */
}

/* Dynamic text body */
.prompter-text-body {
  width: 90%;
  max-width: var(--prompter-margin-width);
  margin: 0 auto;
  font-weight: 500;
  color: var(--text-primary);
  outline: none;
  transition: transform var(--transition-normal);
  transform-origin: center center;
}

/* Mirror Mode Transformation class */
.prompter-text-body.flipped {
  transform: scaleX(-1);
}

/* Typography styles applied dynamically */
.prompter-font-sans { font-family: var(--font-sans); }
.prompter-font-serif { font-family: var(--font-serif); font-weight: 400; }
.prompter-font-mono { font-family: var(--font-mono); }

/* Paragraph & Word styling */
.prompter-paragraph {
  margin-bottom: 2.5em;
  opacity: 0.35;
  transition: opacity var(--transition-normal), color var(--transition-normal);
}

/* Active Highlight Styling */
.prompter-paragraph.active-paragraph {
  opacity: 1;
}

.prompter-word {
  position: relative;
  display: inline-block;
  margin-right: 0.22em;
  padding: 0 2px;
  transition: color 0.15s;
}

/* Spoken word feedback */
.prompter-word.spoken {
  color: var(--accent-secondary);
}

.prompter-word.current-word {
  color: var(--accent-secondary);
  filter: brightness(1.4);
}

/* --- Focus Reading Overlay Zone --- */
.focus-zone {
  position: absolute;
  top: 50%;
  left: 0;
  width: 100%;
  height: 90px;
  transform: translateY(-50%);
  border-top: 1px dashed rgba(255, 255, 255, 0.1);
  border-bottom: 1px dashed rgba(255, 255, 255, 0.1);
  background-color: rgba(255, 255, 255, 0.015);
  backdrop-filter: blur(2px);
  pointer-events: none;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 40px;
  opacity: 0;
  transition: opacity var(--transition-normal);
}

.focus-zone.visible {
  opacity: 1;
}

.focus-zone-indicator {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background-color: var(--accent-primary);
  box-shadow: 0 0 12px var(--accent-primary);
}

.focus-zone-indicator-right {
  width: 0;
  height: 0;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-left: 12px solid var(--accent-primary);
  box-shadow: -4px 0 8px rgba(99, 102, 241, 0.3);
}

/* --- Immersive Floating HUD Control Dashboard --- */
.hud-wrapper {
  position: absolute;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  z-index: 200;
  opacity: 1;
  transition: opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1), transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Auto-hide controls when user is scrolling */
.hud-wrapper.fade-out {
  opacity: 0.08;
  transform: translateX(-50%) translateY(8px);
}

.hud-wrapper:hover {
  opacity: 1 !important;
  transform: translateX(-50%) translateY(0) !important;
}

.hud-container {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--bg-glass);
  border: 1px solid var(--border-color);
  backdrop-filter: blur(20px);
  padding: 10px 24px;
  border-radius: 100px;
  box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.hud-divider {
  width: 1px;
  height: 28px;
  background-color: var(--border-color);
}

.hud-btn {
  background: transparent;
  border: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.hud-btn svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.hud-btn:hover {
  background-color: rgba(255, 255, 255, 0.08);
  color: var(--accent-secondary);
}

.hud-btn.active {
  background-color: var(--accent-primary);
  color: #fff;
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.5);
}

/* Speed Controls on HUD */
.hud-speed-control {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.hud-speed-value {
  width: 60px;
  text-align: center;
  color: var(--accent-secondary);
  font-family: var(--font-mono);
}

/* Microphone indicator pulse animation */
.voice-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 4px 10px;
  border-radius: 20px;
  background-color: rgba(255, 255, 255, 0.04);
}

.voice-indicator.listening {
  color: var(--accent-success);
  background-color: rgba(16, 185, 129, 0.08);
}

.voice-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--text-muted);
}

.listening .voice-dot {
  background-color: var(--accent-success);
  animation: mic-pulse 1.5s infinite ease-in-out;
}

/* ==========================================================================
   Utility Classes & Keyframes
   ========================================================================== */

@keyframes mic-pulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  }
  70% {
    transform: scale(1.2);
    box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background-color: rgba(16, 20, 31, 0.9);
  border: 1px solid var(--border-color);
  backdrop-filter: blur(12px);
  padding: 12px 24px;
  border-radius: var(--border-radius-md);
  box-shadow: var(--shadow-lg);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: all var(--transition-normal);
  z-index: 999;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ==========================================================================
   Responsive Layout
   ========================================================================== */

@media (max-width: 1024px) {
  :root {
    --sidebar-width: 260px;
  }

  .workspace-header {
    padding: 18px 22px;
  }

  .editor-area {
    padding: 24px;
  }

  .config-panel {
    width: 320px;
    padding: 24px 18px;
  }

  .hud-container {
    gap: 10px;
    padding: 8px 16px;
  }
}

@media (max-width: 760px) {
  body {
    height: auto;
    overflow-y: auto;
  }

  #app-container {
    display: block;
    min-height: 100vh;
    min-height: 100dvh;
    height: auto;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .view-panel {
    min-height: 100vh;
    min-height: 100dvh;
  }

  #dashboard-view,
  #dashboard-view.active {
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    height: auto;
    overflow: visible;
    transform: none;
  }

  #dashboard-view.hidden {
    position: absolute;
    transform: none;
  }

  .sidebar {
    width: 100%;
    height: auto;
    max-height: none;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
  }

  .brand {
    padding: 16px;
  }

  .sidebar-actions {
    padding: 14px 16px 10px;
  }

  .scripts-list-title {
    padding: 10px 16px 8px;
  }

  .scripts-list-container {
    display: flex;
    gap: 10px;
    flex-grow: 0;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0 16px 16px;
    scroll-snap-type: x proximity;
  }

  .script-item {
    min-width: min(78vw, 280px);
    margin-bottom: 0;
    scroll-snap-align: start;
  }

  .btn-delete {
    opacity: 1;
  }

  .workspace {
    width: 100%;
    height: auto;
    overflow: visible;
  }

  .workspace-header {
    align-items: stretch;
    flex-direction: column;
    gap: 14px;
    padding: 18px 16px;
  }

  .script-title-input {
    width: 100%;
    font-size: 1.25rem;
  }

  .workspace-actions {
    width: 100%;
  }

  .editor-grid {
    display: flex;
    flex-direction: column;
    height: auto;
    overflow: visible;
  }

  .editor-area {
    min-height: 64vh;
    padding: 16px;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
  }

  .script-textarea {
    min-height: 48vh;
    border-radius: var(--border-radius-md);
    padding: 16px;
    font-size: 1rem;
  }

  .stats-bar {
    flex-wrap: wrap;
    gap: 8px 16px;
    padding: 0 4px;
    font-size: 0.78rem;
  }

  .config-resize-handle {
    display: none;
  }

  .config-panel {
    width: 100% !important;
    min-width: 0;
    max-width: none;
    height: auto;
    overflow: visible;
    padding: 20px 16px 32px;
  }

  .control-group {
    padding: 14px;
  }

  .control-label {
    align-items: flex-start;
    gap: 12px;
  }

  .switch-container {
    align-items: flex-start;
  }

  #prompter-view {
    height: 100vh;
    height: 100dvh;
  }

  .prompter-scroll-viewport {
    padding-top: 42vh;
    padding-top: 42dvh;
    padding-bottom: 58vh;
    padding-bottom: 58dvh;
  }

  .prompter-text-body {
    width: calc(100vw - 32px);
    max-width: calc(100vw - 32px);
    overflow-wrap: break-word;
  }

  .prompter-paragraph {
    margin-bottom: 1.8em;
  }

  .focus-zone {
    height: 74px;
    padding: 0 16px;
  }

  .hud-wrapper {
    bottom: max(12px, env(safe-area-inset-bottom));
    width: calc(100vw - 20px);
  }

  .hud-container {
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px;
    width: 100%;
    padding: 8px;
    border-radius: 22px;
  }

  .hud-btn {
    width: 40px;
    height: 40px;
  }

  .hud-speed-control {
    gap: 4px;
    font-size: 0.78rem;
  }

  .hud-speed-value {
    width: 54px;
  }

  .voice-indicator {
    order: 10;
    width: 100%;
    justify-content: center;
    font-size: 0.75rem;
  }

  .toast {
    bottom: max(88px, calc(env(safe-area-inset-bottom) + 88px));
    width: calc(100vw - 32px);
    justify-content: center;
    padding: 12px 16px;
    text-align: center;
  }
}

@media (max-width: 420px) {
  .brand h1 {
    font-size: 1rem;
  }

  .btn {
    padding: 11px 14px;
  }

  .script-item {
    min-width: 82vw;
    padding: 11px 12px;
  }

  .editor-area {
    min-height: 68vh;
  }

  .hud-divider {
    display: none;
  }

  .hud-btn {
    width: 38px;
    height: 38px;
  }
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast-icon {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--accent-primary);
}

.toast-success .toast-icon {
  background-color: var(--accent-success);
}

.toast-error .toast-icon {
  background-color: var(--accent-error);
}

/* --- Colourblind Mode Overrides --- */
body.colorblind-mode .prompter-word.spoken {
  color: rgba(255, 255, 255, 0.55);
  filter: none;
}

body.colorblind-mode .prompter-word.current-word {
  color: #fde047;
  filter: none;
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-thickness: 2px;
}

body.colorblind-mode .listening .voice-dot {
  background-color: #fde047;
  animation: mic-pulse-cb 1.5s infinite ease-in-out;
}

body.colorblind-mode .voice-indicator.listening {
  color: #fde047;
  background-color: rgba(253, 224, 71, 0.08);
}

@keyframes mic-pulse-cb {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(253, 224, 71, 0.7);
  }
  70% {
    transform: scale(1.2);
    box-shadow: 0 0 0 6px rgba(253, 224, 71, 0);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(253, 224, 71, 0);
  }
}

/* --- Live Style Preview Box --- */
.preview-box-container {
  background-color: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  padding: 16px 12px;
  margin-top: 6px;
  overflow: hidden;
  height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.typography-preview-box {
  color: var(--text-primary);
  text-align: center;
  transition: all var(--transition-fast);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  font-weight: 500;
}
