/* ===== Luciole Font (self-hosted) ===== */
@font-face {
  font-family: 'Luciole';
  src: url('fonts/Luciole-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Luciole';
  src: url('fonts/Luciole-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Luciole';
  src: url('fonts/Luciole-Italic.woff2') format('woff2');
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: 'Luciole';
  src: url('fonts/Luciole-BoldItalic.woff2') format('woff2');
  font-weight: 700;
  font-style: italic;
  font-display: swap;
}

/* ===== CSS Variables & Reset ===== */
:root {
  --primary: #06b6d4;
  --primary-light: #22d3ee;
  --primary-dark: #0891b2;
  --secondary: #06b6d4;
  --success: #06b6d4;
  --danger: #ef4444;

  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f1f5f9;

  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;

  --border-light: #e2e8f0;
  --border-medium: #cbd5e1;

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);

  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-2xl: 1.5rem;

  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 350ms ease;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ===== Dark Mode ===== */
[data-theme="dark"] {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --border-light: #334155;
  --border-medium: #475569;

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4), 0 2px 4px -2px rgb(0 0 0 / 0.3);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.4), 0 4px 6px -4px rgb(0 0 0 / 0.3);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.5), 0 8px 10px -6px rgb(0 0 0 / 0.4);
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===== App Container ===== */
.app-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* ===== Header ===== */
.header {
  text-align: center;
  margin-bottom: 2.5rem;
  padding: 2rem 0;
  position: relative;
}

.dark-mode-toggle {
  position: absolute;
  top: 1rem;
  right: 0;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  border: 1px solid var(--border-light);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 1.25rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.dark-mode-toggle:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  transform: rotate(15deg);
}

[data-theme="dark"] .dark-mode-toggle {
  background: var(--bg-tertiary);
  border-color: var(--border-medium);
  color: #fbbf24;
}

[data-theme="dark"] .dark-mode-toggle:hover {
  background: #fbbf24;
  color: var(--bg-primary);
  border-color: #fbbf24;
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.35rem;
  margin-bottom: 0.75rem;
}

.logo-icon {
  width: auto;
  height: auto;
  background: none;
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  font-size: 3.3rem;
  box-shadow: none;
}

.header h1 {
  font-family: 'Pacifico', cursive;
  font-size: 3.5rem;
  font-weight: 400;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}

.tagline {
  color: var(--text-secondary);
  font-size: 1.125rem;
  font-weight: 400;
}

/* ===== Introduction Card (Collapsible) ===== */
.intro-card {
  background: linear-gradient(135deg, #ecfeff 0%, #cffafe 100%);
  border-radius: var(--radius-2xl);
  padding: 0;
  margin-bottom: 2.5rem;
  box-shadow: var(--shadow-md);
  border: 1px solid #a5f3fc;
  overflow: hidden;
}

[data-theme="dark"] .intro-card {
  background: linear-gradient(135deg, #164e63 0%, #0e7490 100%);
  border-color: #0891b2;
}

.intro-summary {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  cursor: pointer;
  list-style: none;
  user-select: none;
  transition: background var(--transition-fast);
}

.intro-summary::-webkit-details-marker {
  display: none;
}

.intro-summary:hover {
  background: rgba(6, 182, 212, 0.1);
}

.intro-summary h2 {
  flex: 1;
  font-size: 1.125rem;
  font-weight: 600;
  color: #0e7490;
  margin: 0;
}

[data-theme="dark"] .intro-summary h2 {
  color: #67e8f9;
}

.intro-chevron {
  color: #0e7490;
  font-size: 0.875rem;
  transition: transform var(--transition-base);
}

[data-theme="dark"] .intro-chevron {
  color: #67e8f9;
}

.intro-card[open] .intro-chevron {
  transform: rotate(180deg);
}

.intro-icon {
  width: 2.5rem;
  height: 2.5rem;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1rem;
  flex-shrink: 0;
}

.intro-content {
  padding: 0 1.5rem 1.25rem 4.5rem;
  animation: slideDown 0.2s ease-out;
}

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

.intro-content p {
  color: #155e75;
  font-size: 0.9375rem;
  line-height: 1.6;
  margin: 0;
}

[data-theme="dark"] .intro-content p {
  color: #a5f3fc;
}

.help-link-wrapper {
  margin-top: 0.75rem !important;
}

.help-link {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  color: #155e75;
  font-weight: 500;
  font-size: 0.8125rem;
  text-decoration: none;
  transition: opacity var(--transition-fast);
  opacity: 0.7;
}

.help-link:hover {
  opacity: 1;
  text-decoration: underline;
}

[data-theme="dark"] .help-link {
  color: white;
}

[data-theme="dark"] .help-link:hover {
  color: white;
}

/* ===== Main Content ===== */
.main-content {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* ===== Editor Section ===== */
.editor-section {
  background: var(--bg-secondary);
  border-radius: var(--radius-2xl);
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-light);
}

.section-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.section-icon {
  width: 2.5rem;
  height: 2.5rem;
  background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary) 100%);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1rem;
}

.section-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}

.character-count {
  font-size: 0.8125rem;
  color: var(--text-muted);
  background: var(--bg-tertiary);
  padding: 0.375rem 0.75rem;
  border-radius: var(--radius-md);
}

.editor-container {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.editable-text-wrapper {
  position: relative;
  overflow: clip;
  border-radius: var(--radius-xl);
  resize: vertical;
  min-height: 200px;
  max-height: 800px;
}

.editable-text {
  width: 100%;
  height: 100%;
  min-height: inherit;
  max-height: inherit;
  padding: 1.25rem;
  border: 2px solid var(--border-light);
  border-radius: var(--radius-xl);
  font-size: 1.125rem;
  line-height: 1.8;
  color: var(--text-primary);
  background: #fffbeb;
  overflow-y: auto;
  transition: border-color var(--transition-base), box-shadow var(--transition-base);
  outline: none;
  resize: none;
}

.editable-text:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(6, 182, 212, 0.1);
}

.editable-text:empty::before {
  content: attr(placeholder);
  color: var(--text-muted);
  pointer-events: none;
}

/* Text formatting styles inside editable area */
.editable-text h2 {
  font-size: 1.5em;
  font-weight: 700;
  margin: 0.5em 0 0.3em 0;
  color: var(--primary-dark);
}

.editable-text ul,
.editable-text ol {
  margin: 0.5em 0;
  padding-left: 1.5em;
}

.editable-text li {
  margin: 0.25em 0;
}

.editable-text b,
.editable-text strong {
  font-weight: 700;
}

.editable-text i,
.editable-text em {
  font-style: italic;
}

.editable-text u {
  text-decoration: underline;
}

/* Inline heading style (for selected text, not full block) */
.editable-text .inline-heading {
  font-size: 1.4em;
  font-weight: 700;
  color: var(--primary-dark);
}

[data-theme="dark"] .editable-text h2 {
  color: var(--primary-light);
}

[data-theme="dark"] .editable-text .inline-heading {
  color: var(--primary-light);
}

.editor-toolbar {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-start;
}

.toolbar-btn {
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid var(--border-light);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  font-size: 0.875rem;
}

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

.toolbar-btn .toolbar-label {
  margin-left: 0.375rem;
  font-size: 0.8125rem;
  font-weight: 500;
}

.toolbar-btn {
  width: auto;
  padding: 0.5rem 0.875rem;
}

/* ===== Format Toolbar (inline with main toolbar) ===== */
.format-toolbar {
  display: none;
  align-items: center;
  gap: 0.25rem;
  margin-left: auto;
}

.format-toolbar.visible {
  display: flex;
}

.format-separator {
  width: 1px;
  height: 1.5rem;
  background: var(--border-light);
  margin: 0 0.5rem;
}

.format-btn {
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid var(--border-light);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  font-size: 0.875rem;
}

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

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

[data-theme="dark"] .format-btn {
  background: var(--bg-tertiary);
  border-color: var(--border-medium);
}

[data-theme="dark"] .format-btn:hover {
  background: var(--primary);
  border-color: var(--primary);
}


/* Color picker in floating toolbar */
.color-picker-container {
  position: relative;
  display: flex;
  align-items: center;
}

.color-picker-container input[type="color"] {
  position: absolute;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  top: 0;
  left: 0;
}

.color-btn {
  position: relative;
}

.color-indicator {
  position: absolute;
  bottom: 2px;
  left: 50%;
  transform: translateX(-50%);
  width: 12px;
  height: 3px;
  background: #000000;
  border-radius: 2px;
}

/* ===== Controls Grid ===== */
.controls-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.25rem;
}

@media (max-width: 1200px) {
  .controls-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .controls-grid {
    grid-template-columns: 1fr;
  }
}

/* ===== Control Cards ===== */
.control-card {
  background: var(--bg-secondary);
  border-radius: var(--radius-2xl);
  padding: 1.25rem;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-light);
  transition: transform var(--transition-base), box-shadow var(--transition-base);
  min-width: 0;
}

.control-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-light);
}

.card-icon {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1rem;
}

.speech-icon { background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%); }
.typography-icon { background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%); }
.colors-icon { background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%); }
.accessibility-icon { background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%); }

.card-header h3 {
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--text-primary);
}

.card-content {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* ===== Speech Controls ===== */
.speech-controls {
  display: flex;
  justify-content: center;
  gap: 1rem;
  padding: 0.5rem 0;
}

.speech-btn {
  width: 3.5rem;
  height: 3.5rem;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.125rem;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-md);
}

.play-btn {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
}

.play-btn:hover {
  transform: scale(1.1);
  box-shadow: var(--shadow-lg);
}

.play-btn:active {
  transform: scale(0.95);
}

.stop-btn {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

.stop-btn:hover {
  background: var(--danger);
  color: white;
}

/* ===== Control Groups ===== */
.control-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.control-group label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.control-group label i {
  color: var(--primary);
  font-size: 0.8125rem;
}

/* ===== Range Inputs ===== */
.range-container {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

input[type="range"] {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: var(--bg-tertiary);
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: transform var(--transition-fast);
}

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

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  border-radius: 50%;
  cursor: pointer;
  border: none;
  box-shadow: var(--shadow-md);
}

.range-value {
  min-width: 3rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--primary);
  text-align: right;
}

/* ===== Select Inputs ===== */
.select-wrapper {
  position: relative;
}

.select-wrapper select {
  width: 100%;
  padding: 0.625rem 2.5rem 0.625rem 0.875rem;
  font-size: 0.9375rem;
  font-family: inherit;
  color: var(--text-primary);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  transition: all var(--transition-fast);
}

.select-wrapper select:hover {
  border-color: var(--primary);
}

.select-wrapper select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.select-wrapper i {
  position: absolute;
  right: 0.875rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.75rem;
  pointer-events: none;
}

/* ===== Color Controls ===== */
.color-controls {
  display: flex;
  gap: 1.5rem;
}

.color-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.color-group label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.color-picker-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.color-picker-wrapper input[type="color"] {
  width: 100%;
  height: 2.75rem;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  padding: 0;
  background: none;
}

.color-picker-wrapper input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 3px;
}

.color-picker-wrapper input[type="color"]::-webkit-color-swatch {
  border: 2px solid var(--border-light);
  border-radius: var(--radius-sm);
}

/* ===== Color Presets ===== */
.preset-colors {
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-light);
}

.preset-label {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.color-presets {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.preset-btn {
  border: 2px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 0;
  cursor: pointer;
  background: none;
  transition: all var(--transition-fast);
  overflow: hidden;
}

.preset-btn:hover {
  transform: scale(1.1);
  border-color: var(--primary);
}

.preset-sample {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  font-size: 0.875rem;
  font-weight: 600;
}

/* ===== Toggle Switches ===== */
.toggle-group {
  padding: 0.25rem 0;
}

.toggle-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  gap: 1rem;
}

.toggle-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-primary);
  font-size: 0.9375rem;
}

.toggle-info i {
  color: var(--primary);
  font-size: 0.875rem;
}

.toggle-switch {
  position: relative;
  width: 3rem;
  height: 1.625rem;
}

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

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-tertiary);
  border-radius: 1rem;
  transition: all var(--transition-base);
  border: 1px solid var(--border-light);
}

.toggle-slider::before {
  position: absolute;
  content: "";
  height: 1.25rem;
  width: 1.25rem;
  left: 0.125rem;
  bottom: 0.125rem;
  background: white;
  border-radius: 50%;
  transition: all var(--transition-base);
  box-shadow: var(--shadow-sm);
}

.toggle-switch input:checked + .toggle-slider {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  border-color: var(--primary-dark);
}

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

/* ===== Focus Mode Button ===== */
.focus-btn {
  width: 100%;
  padding: 0.875rem 1.25rem;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  border: none;
  border-radius: var(--radius-lg);
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-md);
  margin-top: 0.5rem;
}

.focus-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

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

/* ===== Quick Actions ===== */
.quick-actions {
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1rem 0;
}

.action-btn {
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-lg);
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all var(--transition-fast);
}

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

.reset-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: var(--border-medium);
}

.save-btn {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  border: none;
  box-shadow: var(--shadow-md);
}

.save-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

/* ===== Footer ===== */
.footer {
  margin-top: 3rem;
  padding: 2rem 0;
  border-top: 1px solid var(--border-light);
}

.footer-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.15rem;
  text-align: center;
}

.made-with {
  color: var(--text-secondary);
  font-size: 0.9375rem;
  line-height: 1.6;
}

.made-with i {
  color: var(--primary);
  animation: heartbeat 1.5s ease infinite;
}

@keyframes heartbeat {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

.made-with a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
  transition: color var(--transition-fast);
}

.made-with a:hover {
  color: var(--primary-dark);
}

.footer-support {
  color: var(--text-secondary);
  font-size: 0.9375rem;
  line-height: 1.7;
  max-width: none;
  margin-bottom: 0.5rem;
  white-space: nowrap;
}

.footer-brand-name {
  font-family: 'Pacifico', cursive;
  font-weight: 400;
}

.footer-support-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
  transition: color var(--transition-fast);
}

.footer-support-link:hover {
  color: var(--primary-dark);
  text-decoration: underline;
}

.license img {
  opacity: 0.7;
  transition: opacity var(--transition-fast);
}

.license img:hover {
  opacity: 1;
}

.year {
  color: #000000;
  font-size: 0.8125rem;
}

.year #current-year {
  color: inherit;
}

[data-theme="dark"] .year {
  color: var(--text-secondary);
}

/* ===== Focus Mode Overlay ===== */
.focus-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-primary);
  z-index: 1000;
  display: none;
  opacity: 0;
  transition: opacity var(--transition-slow);
}

.focus-overlay.active {
  display: flex;
  flex-direction: column;
  opacity: 1;
}

.focus-container {
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.exit-focus-btn {
  align-self: flex-end;
  margin-bottom: 2rem;
  padding: 0.75rem 1.25rem;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all var(--transition-fast);
}

.exit-focus-btn:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.focus-text-wrapper {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  border-radius: var(--radius-2xl);
}

.focus-text-area {
  flex: 1;
  padding: 2rem;
  background: var(--bg-secondary);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-xl);
  overflow-y: auto;
  font-size: 1.25rem;
  line-height: 2;
}

.focus-reading-ruler {
  position: absolute;
  left: 0;
  right: 0;
  height: 2.5rem;
  background: transparent;
  border-top: 2px solid #fff;
  border-bottom: 2px solid #fff;
  pointer-events: none;
  display: none;
}

.focus-reading-ruler::before,
.focus-reading-ruler::after {
  content: '';
  position: absolute;
  left: 0;
  width: 100%;
  background: rgba(15, 23, 42, 0.6);
  pointer-events: none;
}

.focus-reading-ruler::before {
  bottom: 100%;
  height: 2000px;
}

.focus-reading-ruler::after {
  top: 100%;
  height: 2000px;
}

/* ===== Reading Ruler ===== */
.reading-ruler {
  position: absolute;
  left: 0;
  top: 50%;
  width: 100%;
  height: 2.5rem;
  background: transparent;
  border-top: 2px solid #fff;
  border-bottom: 2px solid #fff;
  pointer-events: none;
  z-index: 10;
  display: none;
  transform: translateY(-50%);
}

.reading-ruler::before,
.reading-ruler::after {
  content: '';
  position: absolute;
  left: 0;
  width: 100%;
  background: rgba(15, 23, 42, 0.6);
  pointer-events: none;
}

.reading-ruler::before {
  bottom: 100%;
  height: 2000px;
}

.reading-ruler::after {
  top: 100%;
  height: 2000px;
}

.reading-ruler.active {
  display: block;
}

/* ===== Word Definition Popup ===== */
.definition-popup {
  position: absolute;
  z-index: 100;
  width: 320px;
  max-height: 280px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  display: none;
  flex-direction: column;
  overflow: hidden;
  animation: defPopIn 0.2s ease;
}

.definition-popup.active {
  display: flex;
}

@keyframes defPopIn {
  from { opacity: 0; transform: translateY(4px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.definition-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-tertiary);
}

.definition-word {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--primary);
}

.definition-pos {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
}

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

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

.definition-body {
  padding: 0.75rem 1rem;
  overflow-y: auto;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text-primary);
}

.definition-body ol {
  margin: 0;
  padding-left: 1.25rem;
}

.definition-body li {
  margin-bottom: 0.35rem;
}

.definition-body .def-loading {
  text-align: center;
  color: var(--text-muted);
  padding: 1rem 0;
}

.definition-body .def-error {
  text-align: center;
  color: var(--text-muted);
  padding: 1rem 0;
}

/* ===== Toast Notifications ===== */
.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  z-index: 1001;
}

.toast {
  padding: 1rem 1.5rem;
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.9375rem;
  animation: slideIn 0.3s ease forwards;
  border-left: 4px solid var(--primary);
}

.toast.success {
  border-left-color: var(--success);
}

.toast.success i {
  color: var(--success);
}

.toast.error {
  border-left-color: var(--danger);
}

.toast.error i {
  color: var(--danger);
}

.toast i {
  font-size: 1.125rem;
  color: var(--primary);
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideOut {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(100%);
  }
}

/* ===== Line Highlight Overlay ===== */
.line-highlight-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  pointer-events: none;
  z-index: 1;
}

.line-highlight-stripe {
  position: absolute;
  left: 0;
  right: 0;
  background: rgba(6, 182, 212, 0.12);
}

/* Neutralize margins and enforce font size on elements inserted by contenteditable paste */
.editable-text div,
.editable-text p,
.editable-text br {
  margin: 0;
  padding: 0;
}

.editable-text * {
  font-size: inherit !important;
  line-height: inherit !important;
}

/* ===== Bionic Reading Styles ===== */
.editable-text strong {
  font-weight: 700;
}

/* ===== Animations ===== */
[data-animate] {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

[data-animate].animated {
  opacity: 1;
  transform: translateY(0);
}

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
  .app-container {
    padding: 1.5rem 1rem;
  }

  .header h1 {
    font-size: 2rem;
  }

  .tagline {
    font-size: 1rem;
  }

  .intro-card {
    flex-direction: column;
    text-align: center;
    padding: 1.5rem;
  }

  .intro-icon {
    align-self: center;
  }

  .controls-grid {
    grid-template-columns: 1fr;
  }

  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .section-header h2 {
    order: -1;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.75rem;
  }

  .section-icon {
    display: none;
  }

  .character-count {
    align-self: flex-end;
  }

  .quick-actions {
    flex-direction: column;
  }

  .action-btn {
    width: 100%;
    justify-content: center;
  }

  .toast-container {
    left: 1rem;
    right: 1rem;
    bottom: 1rem;
  }

  .toast {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .logo {
    flex-direction: column;
    gap: 0.5rem;
  }

  .header h1 {
    font-size: 1.75rem;
  }

  .speech-controls {
    gap: 0.75rem;
  }

  .speech-btn {
    width: 3rem;
    height: 3rem;
  }

  .color-controls {
    flex-direction: column;
    gap: 1rem;
  }
}

/* ===== Print Styles ===== */
@media print {
  .app-container {
    max-width: none;
  }

  .control-card,
  .quick-actions,
  .intro-card,
  .header,
  .footer {
    display: none;
  }

  .editor-section {
    box-shadow: none;
    border: none;
    padding: 0;
  }

  .editable-text {
    border: none;
    padding: 0;
    max-height: none;
    overflow: visible;
  }
}
