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

:root {
  --bg: #0e0e0e;
  --bg-surface: #161616;
  --bg-raised: #1e1e1e;
  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.16);
  --accent: #f45d22;
  --accent-hover: #ff7a44;
  --accent-dim: rgba(244, 93, 34, 0.14);
  --accent-border: rgba(244, 93, 34, 0.28);
  --text-primary: #f0f0f0;
  --text-secondary: #9a9a9a;
  --text-muted: #666;
  --success: #4ade80;
  --success-dim: rgba(74, 222, 128, 0.12);
  --warning: #fbbf24;
  --warning-dim: rgba(251, 191, 36, 0.12);
  --danger: #f87171;
  --danger-dim: rgba(248, 113, 113, 0.12);
  --noise-opacity: 0.035;
  --shadow-toggle: 0 4px 12px rgba(0, 0, 0, 0.4);
  --font-sans: 'DM Sans', sans-serif;
  --font-mono: 'DM Mono', monospace;
  --radius: 10px;
  --radius-lg: 16px;
}

[data-theme="light"] {
  --bg: #fafaf7;
  --bg-surface: #ffffff;
  --bg-raised: #f3f3ee;
  --border: rgba(0, 0, 0, 0.08);
  --border-hover: rgba(0, 0, 0, 0.18);
  --accent: #e54e15;
  --accent-hover: #f45d22;
  --accent-dim: rgba(229, 78, 21, 0.10);
  --accent-border: rgba(229, 78, 21, 0.28);
  --text-primary: #1a1a1a;
  --text-secondary: #555;
  --text-muted: #888;
  --success: #16a34a;
  --success-dim: rgba(22, 163, 74, 0.10);
  --warning: #d97706;
  --warning-dim: rgba(217, 119, 6, 0.10);
  --danger: #dc2626;
  --danger-dim: rgba(220, 38, 38, 0.10);
  --noise-opacity: 0.025;
  --shadow-toggle: 0 4px 12px rgba(0, 0, 0, 0.08);
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-weight: 400;
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  transition: background-color 0.25s ease, color 0.25s ease;
}

/* Noise texture overlay */
.noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: var(--noise-opacity);
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  background-size: 200px 200px;
}

header, main, footer {
  position: relative;
  z-index: 1;
}

/* Header */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 40px;
  border-bottom: 1px solid var(--border);
  gap: 16px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.logo-icon {
  color: var(--accent);
  font-size: 20px;
}

.logo-text em {
  font-style: normal;
  color: var(--accent);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.badge {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
  background: var(--accent-dim);
  border: 1px solid var(--accent-border);
  padding: 4px 12px;
  border-radius: 100px;
  letter-spacing: 0.02em;
}

/* Theme toggle */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background 0.2s, transform 0.15s;
}

.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
}

.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
[data-theme="light"] .theme-toggle .icon-sun { display: block; }
[data-theme="light"] .theme-toggle .icon-moon { display: none; }

/* Main */
main {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 24px 80px;
}

/* Hero */
.hero {
  padding: 72px 0 48px;
  animation: fadeUp 0.5s ease both;
}

.hero h1 {
  font-size: clamp(42px, 7vw, 68px);
  font-weight: 300;
  line-height: 1.05;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  margin-bottom: 20px;
}

.hero h1 span {
  color: var(--accent);
  font-weight: 500;
}

.hero-sub {
  font-size: 16px;
  color: var(--text-secondary);
  line-height: 1.7;
  max-width: 460px;
}

.hero-by {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 18px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
}

.hero-by a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px dashed var(--accent-border);
  padding-bottom: 1px;
  transition: color 0.2s, border-color 0.2s;
}

.hero-by a:hover {
  color: var(--accent-hover);
  border-bottom-color: var(--accent);
}

/* Dropzone */
.dropzone-section {
  animation: fadeUp 0.5s 0.1s ease both;
  margin-bottom: 32px;
}

.dropzone {
  border: 1px dashed var(--border-hover);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  outline: none;
}

.dropzone:hover,
.dropzone:focus,
.dropzone.drag-over {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.dropzone-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 56px 24px;
  text-align: center;
}

.dropzone-icon {
  color: var(--text-muted);
  margin-bottom: 4px;
  transition: color 0.2s;
}

.dropzone:hover .dropzone-icon,
.dropzone.drag-over .dropzone-icon {
  color: var(--accent);
}

.dropzone-label {
  font-size: 15px;
  color: var(--text-secondary);
  font-weight: 500;
}

.dropzone-sub {
  font-size: 13px;
  color: var(--text-muted);
}

#fileInput {
  display: none;
}

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 13px;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.link-btn:hover {
  opacity: 0.8;
}

/* Results */
.results-section {
  animation: fadeUp 0.3s ease both;
  margin-bottom: 48px;
}

.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.results-count {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.clear-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 6px;
  transition: color 0.2s, background 0.2s;
}

.clear-btn:hover {
  color: var(--danger);
  background: var(--danger-dim);
}

.results-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Result item */
.result-item {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  animation: fadeUp 0.25s ease both;
}

.result-item.state-processing {
  border-color: var(--border);
}
.result-item.state-success {
  border-color: rgba(74, 222, 128, 0.25);
}
.result-item.state-extracted {
  border-color: var(--accent-border);
}
.result-item.state-error {
  border-color: rgba(248, 113, 113, 0.25);
}

.result-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.state-processing .result-status-dot {
  background: var(--text-muted);
  animation: pulse 1.2s ease infinite;
}
.state-success .result-status-dot,
.state-extracted .result-status-dot {
  background: var(--success);
}
.state-error .result-status-dot {
  background: var(--danger);
}

.result-info {
  flex: 1;
  min-width: 0;
}

.result-filename {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.result-label {
  font-size: 12px;
  color: var(--text-muted);
}

.state-success .result-label,
.state-extracted .result-label {
  color: var(--success);
}
.state-error .result-label {
  color: var(--danger);
}

.result-method {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 100px;
  flex-shrink: 0;
  display: none;
}

.state-extracted .result-method {
  display: inline-block;
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid var(--accent-border);
}

.state-success .result-method {
  display: inline-block;
  background: var(--success-dim);
  color: var(--success);
  border: 1px solid rgba(74, 222, 128, 0.25);
}

.download-btn {
  display: none;
  align-items: center;
  gap: 6px;
  background: none;
  border: 1px solid var(--border-hover);
  border-radius: 8px;
  padding: 7px 14px;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: border-color 0.2s, background 0.2s, color 0.2s;
  flex-shrink: 0;
}

.state-success .download-btn,
.state-extracted .download-btn {
  display: flex;
}

.download-btn:hover {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--accent);
}

/* Info section */
.info-section {
  animation: fadeUp 0.5s 0.2s ease both;
  border-top: 1px solid var(--border);
  padding-top: 48px;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
}

.info-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 20px;
  transition: border-color 0.2s;
}

.info-card:hover {
  border-color: var(--border-hover);
}

.info-card-icon {
  font-size: 20px;
  margin-bottom: 12px;
}

.info-card h3 {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.info-card p {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* Footer */
footer {
  position: relative;
  z-index: 1;
  border-top: 1px solid var(--border);
  padding: 28px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
}

.footer-tagline {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.footer-credit {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}

.footer-credit a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s;
}

.footer-credit a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.footer-credit .sep {
  opacity: 0.5;
}

/* Animations */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* Responsive */
@media (max-width: 600px) {
  header {
    padding: 16px 20px;
  }

  .badge {
    display: none;
  }

  main {
    padding: 0 16px 60px;
  }

  .hero {
    padding: 48px 0 36px;
  }

  .result-item {
    flex-wrap: wrap;
  }

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

  footer {
    padding: 22px 20px;
  }
}
