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

/* Fonts loaded in HTML */

:root {
  /* Typography Scale */
  --font-size-xs: 11px;
  --font-size-sm: 13px;
  --font-size-base: 15px;
  --font-size-lg: 18px;
  --font-size-xl: 24px;
  --font-size-2xl: 32px;
  --font-size-3xl: 48px;
  --font-size-4xl: 64px;
  --font-size-5xl: 96px;
  
  /* Light Mode Colors */
  --color-bg: #faf7f2;
  --color-text: #1a1611;
  --color-text-light: #3c2a21;
  --color-text-muted: #6b5b73;
  --color-text-subtle: #9b8c8c;
  --color-border: #d4c4b0;
  --color-accent: #8b4513;
  --color-input-bg: rgba(255, 255, 255, 0.6);
  --color-input-bg-focus: rgba(255, 255, 255, 0.9);
  --color-current-word-bg: rgba(139, 69, 19, 0.1);
  --color-current-word-bg-mid: rgba(139, 69, 19, 0.15);
  --color-control-bg: rgba(26, 22, 17, 0.8);
  --color-control-bg-hover: rgba(26, 22, 17, 0.95);
  --color-control-text: #faf7f2;
  
  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  --space-3xl: 64px;
  --space-4xl: 96px;
  
  /* Grid */
  --grid-margin: clamp(20px, 5vw, 80px);
  --content-width: min(1200px, calc(100vw - 2 * var(--grid-margin)));
}

/* Dark Mode Colors */
body.dark-mode {
  --color-bg: #0f0e0d;
  --color-text: #e8e3dc;
  --color-text-light: #d1c7b8;
  --color-text-muted: #a8998f;
  --color-text-subtle: #736660;
  --color-border: #3a332b;
  --color-accent: #d4a574;
  --color-input-bg: rgba(0, 0, 0, 0.3);
  --color-input-bg-focus: rgba(0, 0, 0, 0.5);
  --color-current-word-bg: rgba(212, 165, 116, 0.15);
  --color-current-word-bg-mid: rgba(212, 165, 116, 0.2);
  --color-control-bg: rgba(232, 227, 220, 0.9);
  --color-control-bg-hover: rgba(232, 227, 220, 0.95);
  --color-control-text: #0f0e0d;
}

body {
  --framer-font-family: "Inter Display", "Inter Display Placeholder", sans-serif;
  --framer-font-family-bold: "Inter Display", "Inter Display Placeholder", sans-serif;  
  --framer-font-open-type-features: 'ss07' on;
  --framer-font-size: var(--font-size-base);
  --framer-font-style: normal;
  --framer-font-weight: 400;
  --framer-letter-spacing: -0.01em;
  --framer-line-height: 1.4;
  --framer-text-color: var(--color-text);
  
  font-family: var(--framer-font-family);
  font-size: var(--framer-font-size);
  font-weight: var(--framer-font-weight);
  color: var(--framer-text-color);
  letter-spacing: var(--framer-letter-spacing);
  line-height: var(--framer-line-height);
  font-feature-settings: var(--framer-font-open-type-features);
  
  background-color: var(--color-bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Layout */
.app {
  min-height: 100vh;
}

.grid-container {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: var(--grid-margin);
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 100vh;
  gap: var(--space-2xl);
}

/* Masthead */
.masthead {
  text-align: center;
  margin-bottom: var(--space-lg);
}

.header-top {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  position: relative;
  margin-bottom: var(--space-md);
}

.title {
  font-family: "Eczar", serif;
  font-optical-sizing: auto;
  font-size: clamp(var(--font-size-3xl), 8vw, var(--font-size-4xl));
  font-weight: 800;
  font-style: normal;
  line-height: 0.85;
  letter-spacing: -0.04em;
  color: var(--color-text);
  margin: 0;
}

.theme-toggle {
  position: absolute;
  right: 0;
  top: 0;
  width: 40px;
  height: 40px;
  border: 1px solid var(--color-border);
  background: var(--color-input-bg);
  color: var(--color-text);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: all 0.2s ease;
}

.theme-toggle:hover {
  background: var(--color-input-bg-focus);
  transform: translateY(-1px);
}

.intro-text {
  font-size: var(--font-size-base);
  line-height: 1.5;
  color: var(--color-text-light);
  margin-bottom: var(--space-lg);
  font-weight: 400;
}

.controls-hint {
  display: flex;
  justify-content: center;
  gap: var(--space-lg);
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  font-weight: 500;
}

.controls-hint span {
  position: relative;
  padding-left: var(--space-md);
}

.controls-hint span::before {
  content: "→";
  position: absolute;
  left: 0;
  color: var(--color-border);
}

/* Input Section */
.input-section {
  border-top: 1px solid var(--color-border);
  padding-top: var(--space-lg);
}

.input-tabs {
  display: flex;
  gap: 2px;
  margin-bottom: var(--space-lg);
  border-radius: 0;
  overflow: hidden;
  border: 1px solid var(--color-border);
}

.input-tab {
  flex: 1;
  padding: var(--space-sm) var(--space-md);
  font-family: var(--framer-font-family);
  font-size: var(--font-size-sm);
  font-weight: 500;
  letter-spacing: 0.01em;
  background: var(--color-input-bg);
  color: var(--color-text-muted);
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  text-transform: none;
}

.input-tab:hover {
  background: var(--color-input-bg-focus);
  color: var(--color-text-light);
}

.input-tab.active {
  background: var(--color-text);
  color: var(--color-control-text);
}

.input-group {
  margin-bottom: var(--space-lg);
}

.input-label {
  display: block;
  font-size: var(--font-size-sm);
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--color-text);
  margin-bottom: var(--space-md);
}

.text-input {
  width: 100%;
  min-height: 120px;
  padding: var(--space-md);
  font-family: "Eczar", serif;
  font-optical-sizing: auto;
  font-style: normal;
  font-size: var(--font-size-base);
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-input-bg);
  border: 1px solid var(--color-border);
  border-radius: 0;
  resize: vertical;
  transition: all 0.2s ease;
}

.text-input:focus {
  outline: none;
  border-color: var(--color-text-light);
  background: var(--color-input-bg-focus);
  box-shadow: 0 0 0 1px var(--color-text-light);
}

.text-input::placeholder {
  color: var(--color-text-subtle);
  font-style: italic;
}

/* PDF Upload */
.pdf-upload-area {
  min-height: 120px;
  border: 2px dashed var(--color-border);
  border-radius: 8px;
  background: var(--color-input-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
}

.pdf-upload-area:hover:not(.processing) {
  border-color: var(--color-text-light);
  background: var(--color-input-bg-focus);
  transform: translateY(-1px);
}

.pdf-upload-area.drag-over {
  border-color: var(--color-text);
  background: var(--color-input-bg-focus);
  transform: scale(1.02);
}

.pdf-upload-area.processing {
  cursor: not-allowed;
  border-style: solid;
  border-color: var(--color-text-muted);
}

.pdf-upload-area.has-file {
  border-style: solid;
  border-color: var(--color-accent);
  background: var(--color-input-bg-focus);
}

/* Upload Content */
.upload-content {
  text-align: center;
  padding: var(--space-md);
}

.upload-icon {
  font-size: 32px;
  margin-bottom: var(--space-sm);
  opacity: 0.7;
}

.upload-text {
  font-size: var(--font-size-base);
  color: var(--color-text-light);
  margin-bottom: var(--space-xs);
  font-weight: 500;
}

.upload-hint {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin: 0;
}

/* Processing Content */
.processing-content {
  text-align: center;
  padding: var(--space-md);
}

.processing-spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--color-border);
  border-top: 2px solid var(--color-text);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto var(--space-sm);
}

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

.processing-text {
  font-size: var(--font-size-base);
  color: var(--color-text-light);
  margin-bottom: var(--space-xs);
  font-weight: 500;
}

.processing-progress {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin: 0;
}

/* File Info */
.file-info {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  width: 100%;
}

.file-icon {
  font-size: 24px;
  color: var(--color-accent);
  flex-shrink: 0;
}

.file-name {
  font-size: var(--font-size-base);
  color: var(--color-text-light);
  font-weight: 500;
  margin: 0 0 var(--space-xs) 0;
  word-break: break-word;
}

.file-status {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin: 0;
}

.clear-file {
  width: 24px;
  height: 24px;
  border: none;
  background: var(--color-text-muted);
  color: var(--color-control-text);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  margin-left: auto;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.clear-file:hover {
  background: var(--color-text);
  transform: scale(1.1);
}

/* URL Input */
.url-input-area {
  display: flex;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.url-input {
  flex: 1;
  padding: var(--space-md);
  font-family: var(--framer-font-family);
  font-size: var(--font-size-sm);
  color: var(--color-text);
  background: var(--color-input-bg);
  border: 1px solid var(--color-border);
  border-radius: 0;
  transition: all 0.2s ease;
}

.url-input:focus {
  outline: none;
  border-color: var(--color-text-light);
  background: var(--color-input-bg-focus);
  box-shadow: 0 0 0 1px var(--color-text-light);
}

.url-input::placeholder {
  color: var(--color-text-subtle);
  font-style: italic;
}

.extract-button {
  padding: var(--space-md) var(--space-lg);
  font-family: var(--framer-font-family);
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-control-text);
  background: var(--color-text);
  border: 1px solid var(--color-text);
  border-radius: 0;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.extract-button:hover:not(:disabled) {
  background: var(--color-text-light);
  border-color: var(--color-text-light);
  transform: translateY(-1px);
}

.extract-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

/* Extraction Progress */
.extraction-progress {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) 0;
  justify-content: center;
}

/* Article Info */
.article-info {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--color-input-bg-focus);
  border: 1px solid var(--color-accent);
  border-radius: 4px;
  margin-bottom: var(--space-md);
}

.article-icon {
  font-size: 24px;
  color: var(--color-accent);
  flex-shrink: 0;
}

.article-details {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  position: relative;
}

.article-title {
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--color-text);
  margin: 0;
  line-height: 1.3;
}

.article-stats {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin: 0;
}

.clear-article {
  position: absolute;
  top: 0;
  right: 0;
  width: 24px;
  height: 24px;
  border: none;
  background: var(--color-text-muted);
  color: var(--color-control-text);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all 0.2s ease;
}

.clear-article:hover {
  background: var(--color-text);
  transform: scale(1.1);
}

/* URL Error */
.url-error {
  margin-top: var(--space-md);
  padding: var(--space-md);
  background: rgba(220, 38, 127, 0.1);
  border: 1px solid rgba(220, 38, 127, 0.3);
  border-radius: 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-md);
}

.url-error p {
  color: var(--color-text-light);
  font-size: var(--font-size-sm);
  margin: 0;
  flex: 1;
}

/* PDF Error */
.pdf-error {
  margin-top: var(--space-md);
  padding: var(--space-md);
  background: rgba(220, 38, 127, 0.1);
  border: 1px solid rgba(220, 38, 127, 0.3);
  border-radius: 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-md);
}

.pdf-error p {
  color: var(--color-text-light);
  font-size: var(--font-size-sm);
  margin: 0;
  flex: 1;
}

.dismiss-error {
  padding: var(--space-xs) var(--space-sm);
  font-size: var(--font-size-xs);
  font-weight: 500;
  background: transparent;
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.dismiss-error:hover {
  background: var(--color-input-bg);
  color: var(--color-text-light);
}

/* Text Analysis */
.text-analysis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--color-input-bg);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  margin-bottom: var(--space-lg);
}

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

.analysis-label {
  font-size: var(--font-size-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--color-text-muted);
}

.analysis-value {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text);
}

.suggested-wpm {
  color: var(--color-accent);
  cursor: pointer;
  transition: all 0.2s ease;
}

.suggested-wpm:hover {
  color: var(--color-text);
  transform: translateY(-1px);
}

/* Settings Bar */
.settings-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: var(--space-md);
  padding-top: var(--space-md);
  border-top: 1px solid var(--color-border);
}

.speed-setting {
  flex: 1;
  min-width: 200px;
}

.setting-label {
  display: block;
  font-size: var(--font-size-xs);
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: var(--space-sm);
}

.speed-selector {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.speed-slider {
  flex: 1;
  height: 2px;
  background: var(--color-border);
  border-radius: 1px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.speed-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  background: var(--color-text);
  border-radius: 50%;
  cursor: pointer;
}

.speed-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  background: var(--color-text);
  border-radius: 50%;
  cursor: pointer;
  border: none;
}

.speed-display {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text);
  min-width: 60px;
  text-align: right;
}

.start-button {
  padding: var(--space-md) var(--space-2xl);
  font-family: var(--framer-font-family);
  font-size: var(--font-size-base);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--color-control-text);
  background: var(--color-text);
  border: 1px solid var(--color-text);
  border-radius: 0;
  cursor: pointer;
  transition: all 0.2s ease;
  text-transform: none;
}

.start-button:hover:not(:disabled) {
  background: var(--color-text-light);
  border-color: var(--color-text-light);
  transform: translateY(-1px);
}

.start-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

/* Reading Mode */
.reading-mode {
  background: var(--color-bg);
}

.reading-mode-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-3xl) var(--space-lg);
  position: relative;
}

.reading-content {
  max-width: 800px;
  width: 100%;
}

.reading-text {
  font-family: "Eczar", serif;
  font-optical-sizing: auto;
  font-size: clamp(18px, 2.5vw, 24px);
  font-weight: 400;
  font-style: normal;
  letter-spacing: -0.01em;
  line-height: 1.6;
  color: var(--color-text);
  text-align: left;
}

.word {
  transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.word.current {
  color: var(--color-text);
  font-weight: 500;
  background: linear-gradient(90deg, 
    var(--color-current-word-bg) 0%, 
    var(--color-current-word-bg-mid) 50%, 
    var(--color-current-word-bg) 100%);
  padding: 2px 4px;
  border-radius: 2px;
}

.word.past {
  color: var(--color-text-subtle);
}

/* Reading Controls */
.reading-controls {
  position: fixed;
  bottom: var(--space-2xl);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: var(--space-sm);
  opacity: 0.6;
  transition: opacity 0.3s ease;
}

.reading-controls:hover {
  opacity: 1;
}

.control-btn {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  background: var(--color-control-bg);
  color: var(--color-control-text);
  border: 1px solid var(--color-control-bg);
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s ease;
  backdrop-filter: blur(10px);
}

.control-btn:hover {
  background: var(--color-control-bg-hover);
  transform: translateY(-1px);
}

/* Responsive Design */
@media (max-width: 768px) {
  .settings-bar {
    flex-direction: column;
    align-items: stretch;
  }
  
  .start-button {
    width: 100%;
    text-align: center;
  }
  
  .reading-mode-container {
    padding: var(--space-2xl) var(--space-md);
  }
}

@media (max-width: 480px) {
  .title {
    font-size: var(--font-size-3xl);
  }
  
  .controls-hint {
    flex-direction: column;
    gap: var(--space-sm);
  }
  
  .input-tabs {
    flex-direction: column;
  }
  
  .file-info {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-sm);
  }
  
  .clear-file {
    align-self: flex-end;
    margin: 0;
  }
}