/* ── Theme Variables ── */
:root {
  --bg-primary:       #ffffff;
  --bg-secondary:     #f9fafb;
  --bg-tertiary:      #f3f4f6;
  --bg-card:          #ffffff;
  --text-primary:     #111827;
  --text-secondary:   #4b5563;
  --text-muted:       #6b7280;
  --text-hint:        #9ca3af;
  --border-primary:   #e5e7eb;
  --border-secondary: #d1d5db;
  --teal:             #0d9488;
  --teal-hover:       #0f766e;
  --teal-light:       #f0fdf9;
  --teal-border:      #99f6e4;
  --navbar-bg:        #ffffff;
  --navbar-border:    #f3f4f6;
  --input-bg:         #f9fafb;
  --drop-zone-bg:     #f9fafb;
  --result-bg:        #f0fdf9;
  --shadow:           rgba(0,0,0,0.08);
  --hero-bg:          #e6faf6;
}

[data-theme="dark"] {
  --bg-primary:       #111827;
  --bg-secondary:     #1f2937;
  --bg-tertiary:      #1a2433;
  --bg-card:          #1f2937;
  --text-primary:     #f9fafb;
  --text-secondary:   #d1d5db;
  --text-muted:       #9ca3af;
  --text-hint:        #6b7280;
  --border-primary:   #374151;
  --border-secondary: #4b5563;
  --teal:             #0d9488;
  --teal-hover:       #14b8a6;
  --teal-light:       #0d2420;
  --teal-border:      #134e4a;
  --navbar-bg:        #1f2937;
  --navbar-border:    #374151;
  --input-bg:         #111827;
  --drop-zone-bg:     #1a2433;
  --result-bg:        #0d2420;
  --shadow:           rgba(0,0,0,0.3);
  --hero-bg:          #0d2420;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg-primary:       #111827;
    --bg-secondary:     #1f2937;
    --bg-tertiary:      #1a2433;
    --bg-card:          #1f2937;
    --text-primary:     #f9fafb;
    --text-secondary:   #d1d5db;
    --text-muted:       #9ca3af;
    --text-hint:        #6b7280;
    --border-primary:   #374151;
    --border-secondary: #4b5563;
    --teal:             #0d9488;
    --teal-hover:       #14b8a6;
    --teal-light:       #0d2420;
    --teal-border:      #134e4a;
    --navbar-bg:        #1f2937;
    --navbar-border:    #374151;
    --input-bg:         #111827;
    --drop-zone-bg:     #1a2433;
    --result-bg:        #0d2420;
    --shadow:           rgba(0,0,0,0.3);
    --hero-bg:          #0d2420;
  }
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg-secondary);
  color: var(--text-primary);
  line-height: 1.6;
  transition: background 0.2s, color 0.2s;
}
a { text-decoration: none; color: inherit; }

@font-face {
  font-family: "RussoOne";
  src: url("/fonts/RussoOne-Regular.ttf") format("truetype");
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

/* ── Navbar ── */
.navbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--navbar-bg);
  border-bottom: 1px solid var(--navbar-border);
  padding: 1rem 1.5rem;
  transition: background 0.2s;
}
.navbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.navbar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 1px;
  font-family: "RussoOne", sans-serif;
}
.navbar-logo-icon {
  width: 32px;
  height: 32px;
  background: var(--teal);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1rem;
}
.navbar-links {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}
.navbar-links a {
  font-size: 0.875rem;
  color: var(--text-muted);
  transition: color 0.15s;
}
.navbar-links a:hover { color: var(--teal); }

/* Theme toggle */
.theme-toggle-btn {
  background: none;
  border: 1px solid var(--border-primary);
  border-radius: 8px;
  padding: 0.375rem 0.5rem;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1.125rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  line-height: 1;
}
.theme-toggle-btn:hover {
  border-color: var(--teal);
  color: var(--teal);
  background: var(--teal-light);
}

/* ── Hero ── */
.hero {
  background: var(--hero-bg);
  padding: 5rem 1.5rem 4rem;
  text-align: center;
  transition: background 0.2s;
}
.hero h1 {
  font-size: 2.75rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.15;
  margin-bottom: 1rem;
  letter-spacing: -1px;
}
.hero h1 span { color: var(--teal); }
.hero p {
  font-size: 1.0625rem;
  color: var(--text-secondary);
  max-width: 560px;
  margin: 0 auto 2rem;
  line-height: 1.75;
}
.hero-search {
  display: flex;
  gap: 0.5rem;
  max-width: 480px;
  margin: 0 auto;
}
.hero-search input {
  flex: 1;
  border: 1px solid var(--border-secondary);
  border-radius: 10px;
  padding: 0.75rem 1.125rem;
  font-size: 0.9375rem;
  background: var(--bg-card);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s;
}
.hero-search input::placeholder { color: var(--text-hint); }
.hero-search input:focus { border-color: var(--teal); }
.hero-search button {
  background: var(--teal);
  color: white;
  border: none;
  padding: 0.75rem 1.25rem;
  border-radius: 10px;
  font-size: 0.9375rem;
  cursor: pointer;
  transition: background 0.15s;
  font-weight: 500;
}
.hero-search button:hover { background: var(--teal-hover); }

/* ── Stats bar ── */
.stats-bar {
  background: var(--bg-card);
  border-top: 1px solid var(--border-primary);
  border-bottom: 1px solid var(--border-primary);
  padding: 1.25rem 1.5rem;
  transition: background 0.2s;
}
.stats-inner {
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  justify-content: center;
  gap: 3rem;
  flex-wrap: wrap;
  text-align: center;
}
.stat-num {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--teal);
}
.stat-label {
  font-size: 0.8125rem;
  color: var(--text-hint);
  margin-top: 2px;
}

/* ── Category sections ── */
.categories-section {
  max-width: 1100px;
  margin: 0 auto;
  padding: 3rem 1.5rem;
}
.category-block { margin-bottom: 3rem; }
.category-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--teal-light);
  display: flex;
  align-items: center;
  gap: 8px;
}
.category-title i { color: var(--teal); }
.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.625rem;
}
.tool-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0.5rem 0.875rem;
  background: var(--bg-card);
  border: 1px solid var(--border-primary);
  border-radius: 8px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.15s;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tool-chip:hover {
  border-color: var(--teal);
  color: var(--teal);
  background: var(--teal-light);
}
.tool-chip-from {
  font-weight: 700;
  color: var(--text-primary);
  flex-shrink: 0;
}
.tool-chip:hover .tool-chip-from { color: var(--teal); }
.tool-chip i {
  color: var(--text-hint);
  font-size: 0.75rem;
  flex-shrink: 0;
}
.tool-chip:hover i { color: var(--teal); }

/* Search highlight */
.tool-chip.hidden { display: none; }
.category-block.hidden { display: none; }

/* ── Converter page ── */
.converter-wrapper {
  max-width: 720px;
  margin: 2.5rem auto;
  padding: 0 1.5rem;
}
.converter-box {
  background: var(--bg-card);
  border: 1px solid var(--border-primary);
  border-radius: 14px;
  padding: 2rem;
  transition: background 0.2s;
}
.converter-box h1 {
  font-size: 1.625rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.375rem;
}
.converter-desc {
  font-size: 0.9375rem;
  color: var(--text-muted);
  margin-bottom: 1.75rem;
  line-height: 1.6;
}
.format-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--teal-light);
  color: var(--teal);
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--teal-border);
  margin-bottom: 1.5rem;
}

/* Drop zone */
.drop-zone {
  border: 2px dashed var(--border-secondary);
  border-radius: 12px;
  padding: 2.5rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  background: var(--drop-zone-bg);
  margin-bottom: 1.25rem;
}
.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--teal);
  background: var(--teal-light);
}
.drop-zone i {
  font-size: 2.25rem;
  color: var(--text-hint);
  display: block;
  margin-bottom: 0.75rem;
}
.drop-zone p {
  font-size: 0.9375rem;
  color: var(--text-muted);
  margin-bottom: 0.375rem;
}
.drop-zone small { font-size: 0.8125rem; color: var(--text-hint); }
.drop-zone input[type="file"] { display: none; }

/* File selected */
.file-selected {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--teal-light);
  border: 1px solid var(--teal-border);
  border-radius: 8px;
  margin-bottom: 1.25rem;
}
.file-selected i { color: var(--teal); font-size: 1.25rem; }
.file-selected span {
  font-size: 0.875rem;
  color: var(--text-primary);
  font-weight: 500;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-selected button {
  background: none;
  border: none;
  color: var(--text-hint);
  cursor: pointer;
  font-size: 1rem;
  padding: 0;
}
.file-selected button:hover { color: #dc2626; }

/* Output format selector */
.format-selector {
  margin-bottom: 1.25rem;
}
.format-selector label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}
.format-select {
  width: 100%;
  border: 1px solid var(--border-primary);
  border-radius: 8px;
  padding: 0.625rem 0.875rem;
  font-size: 0.9375rem;
  color: var(--text-primary);
  background: var(--input-bg);
  outline: none;
  transition: border-color 0.15s;
  cursor: pointer;
}
.format-select:focus { border-color: var(--teal); }

/* Buttons */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--teal);
  color: white;
  padding: 0.75rem 1.5rem;
  border-radius: 10px;
  font-size: 0.9375rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: background 0.15s;
  width: 100%;
}
.btn-primary:hover { background: var(--teal-hover); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--teal);
  color: white;
  padding: 0.625rem 1.5rem;
  border-radius: 8px;
  font-size: 0.9375rem;
  font-weight: 500;
  transition: background 0.15s;
  text-decoration: none;
}
.btn-download:hover { background: var(--teal-hover); color: white; }

/* Result box */
.result-box {
  margin-top: 1.25rem;
  padding: 1.25rem;
  background: var(--result-bg);
  border: 1px solid var(--teal-border);
  border-radius: 10px;
  text-align: center;
}
.result-box p {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--teal);
  margin-bottom: 0.75rem;
}

/* Status */
.status-text { margin-top: 1rem; font-size: 0.9375rem; color: var(--text-muted); }

/* Progress bar */
.progress-bar-wrapper {
  margin-top: 1rem;
  background: var(--bg-tertiary);
  border-radius: 999px;
  height: 6px;
  overflow: hidden;
  display: none;
}
.progress-bar-fill {
  height: 100%;
  background: var(--teal);
  border-radius: 999px;
  width: 0%;
  transition: width 0.3s;
  animation: progressPulse 1.5s ease-in-out infinite;
}
@keyframes progressPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* Related tools */
.related-tools {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-primary);
}
.related-tools h3 {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.875rem;
}
.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.5rem;
}
.related-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0.5rem 0.75rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: 8px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.15s;
  text-decoration: none;
}
.related-chip:hover {
  border-color: var(--teal);
  color: var(--teal);
  background: var(--teal-light);
}

/* ── Footer ── */
.footer {
  background: var(--bg-card);
  border-top: 1px solid var(--border-primary);
  padding: 2rem 1.5rem;
  margin-top: 4rem;
  transition: background 0.2s;
}
.footer-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  text-align: center;
}
@media (min-width: 640px) {
  .footer-inner {
    flex-direction: row;
    justify-content: space-between;
    text-align: left;
  }
}
.footer-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 1px;
  font-family: "RussoOne", sans-serif;
}
.footer-logo-icon {
  width: 24px;
  height: 24px;
  background: var(--teal);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 0.75rem;
}
.footer-links {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
  justify-content: center;
}
.footer-links a {
  font-size: 0.75rem;
  color: var(--text-muted);
  transition: color 0.15s;
}
.footer-links a:hover { color: var(--teal); }
.footer-copy { font-size: 0.75rem; color: var(--text-hint); }

/* ── Responsive ── */
@media (max-width: 640px) {
  .hero h1 { font-size: 1.875rem; }
  .converter-box { padding: 1.25rem; }
  .stats-inner { gap: 1.5rem; }
  .navbar-links a:not(:last-child) { display: none; }
}

/* ── 404 page ── */
.not-found {
  text-align: center;
  padding: 6rem 1.5rem;
  color: var(--text-hint);
}
.not-found i { font-size: 3.5rem; display: block; margin-bottom: 1rem; color: var(--border-secondary); }
.not-found h1 { font-size: 1.5rem; color: var(--text-primary); margin-bottom: 0.5rem; }
.not-found p { font-size: 0.9375rem; margin-bottom: 1.5rem; }

/* ── File Preview ── */
.live-preview-wrapper {
  margin-bottom: 1.25rem;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border-primary);
  background: var(--bg-tertiary);
  display: none;
}
.live-preview-wrapper.visible { display: block; }
.live-preview-inner {
  position: relative;
  width: 100%;
}
.live-preview-inner img,
.live-preview-inner video,
.live-preview-inner audio {
  width: 100%;
  display: block;
  max-height: 320px;
  object-fit: contain;
  background: var(--bg-tertiary);
}
.live-preview-inner audio { padding: 1rem; }
.live-preview-label {
  padding: 0.5rem 0.875rem;
  font-size: 0.75rem;
  color: var(--text-hint);
  background: var(--bg-card);
  border-top: 1px solid var(--border-primary);
  display: flex;
  justify-content: space-between;
}

/* ── Result preview ── */
.result-preview {
  margin-bottom: 1.25rem;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border-primary);
  background: var(--bg-tertiary);
}
.result-preview img {
  width: 100%;
  max-height: 400px;
  object-fit: contain;
  display: block;
  background: var(--bg-tertiary);
}
.result-preview video,
.result-preview audio {
  width: 100%;
  display: block;
}
.result-preview audio { padding: 1rem; }
.result-preview-placeholder {
  padding: 2rem;
  text-align: center;
  color: var(--text-hint);
}
.result-preview-placeholder i {
  font-size: 2.5rem;
  display: block;
  margin-bottom: 0.75rem;
}
.result-preview-placeholder p { font-size: 0.9375rem; }

/* ── Editor selector ── */
.editor-selector {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-primary);
}
.editor-selector-title {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-hint);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.875rem;
}
.editor-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.editor-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0.5rem 0.875rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: 8px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}
.editor-chip:hover {
  border-color: var(--teal);
  color: var(--teal);
  background: var(--teal-light);
}
.editor-chip i { font-size: 0.875rem; }