:root {
  /* Dark Theme (Default) */
  --bg: #0d0f14;
  --bg-pattern: radial-gradient(ellipse at 50% -10%, rgba(212, 245, 66, 0.07) 0%, transparent 60%);
  --grid-line: rgba(255, 255, 255, 0.025);
  --surface: #141720;
  --surface2: #1c202c;
  --surface-hover: #242938;
  --border: #2b3142;
  --border2: #383f54;
  
  --accent: #d4f542;
  --accent2: #b8db2a;
  --accent-text: #0d0f14;
  --accent-subtle: rgba(212, 245, 66, 0.12);
  --accent-subtle-hover: rgba(212, 245, 66, 0.18);
  --accent-glow: 0 4px 16px rgba(212, 245, 66, 0.2);
  
  --text: #edf0f7;
  --text-secondary: #9da5bc;
  --muted: #6e768e;
  
  --header-bg: rgba(20, 23, 32, 0.85);
  --nav-bg: rgba(255, 255, 255, 0.04);
  --card-bg: rgba(20, 23, 32, 0.92);
  --hero-bg: linear-gradient(135deg, rgba(20, 23, 32, 0.95), rgba(28, 32, 44, 0.9));
  --dropzone-bg: linear-gradient(135deg, rgba(20, 23, 32, 0.95), rgba(28, 32, 44, 0.92));
  --action-bar-bg: rgba(20, 23, 32, 0.88);
  
  --logo-gradient: linear-gradient(135deg, #f7fb86 0%, #d4f542 60%, #a8db22 100%);
  --logo-shadow: 0 6px 14px rgba(212, 245, 66, 0.18);
  --title-color: #d4f542;
  --title-shadow: 0 2px 12px rgba(212, 245, 66, 0.15);
  
  --danger: #ff5252;
  --danger-bg: rgba(255, 82, 82, 0.12);
  --success: #3ddc84;
  --success-bg: rgba(61, 220, 132, 0.12);
  --warn: #f59e0b;
  --warn-bg: rgba(245, 158, 11, 0.12);
  
  --radius: 16px;
  --radius-sm: 10px;
  --radius-full: 9999px;
  --mono: 'DM Mono', monospace;
  --display: 'Syne', sans-serif;
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 12px 36px rgba(0, 0, 0, 0.35);
  --toast-bg: #1c202c;
}

[data-theme="light"] {
  /* Light Theme: Eye-friendly, high-contrast, zero glare */
  --bg: #f4f6f9;
  --bg-pattern: radial-gradient(ellipse at 50% -10%, rgba(16, 149, 74, 0.05) 0%, transparent 60%);
  --grid-line: rgba(0, 0, 0, 0.035);
  --surface: #ffffff;
  --surface2: #edf1f7;
  --surface-hover: #e2e7ef;
  --border: #dbe1ea;
  --border2: #cbd4e1;
  
  --accent: #15803d;
  --accent2: #166534;
  --accent-text: #ffffff;
  --accent-subtle: rgba(21, 128, 61, 0.1);
  --accent-subtle-hover: rgba(21, 128, 61, 0.16);
  --accent-glow: 0 4px 14px rgba(21, 128, 61, 0.18);
  
  --text: #0f172a;
  --text-secondary: #334155;
  --muted: #64748b;
  
  --header-bg: rgba(255, 255, 255, 0.9);
  --nav-bg: rgba(0, 0, 0, 0.04);
  --card-bg: #ffffff;
  --hero-bg: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  --dropzone-bg: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  --action-bar-bg: rgba(255, 255, 255, 0.95);
  
  --logo-gradient: linear-gradient(135deg, #15803d 0%, #16a34a 60%, #22c55e 100%);
  --logo-shadow: none;
  --title-color: #0f172a;
  --title-shadow: none;
  
  --danger: #dc2626;
  --danger-bg: rgba(220, 38, 38, 0.08);
  --success: #15803d;
  --success-bg: rgba(21, 128, 61, 0.1);
  --warn: #d97706;
  --warn-bg: rgba(217, 119, 6, 0.1);
  
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.07);
  --toast-bg: #ffffff;
}

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

html {
  background-color: var(--bg);
  min-height: 100%;
  scroll-behavior: smooth;
  transition: background-color 0.25s ease;
}

body {
  font-family: var(--display);
  background: transparent;
  color: var(--text);
  min-height: 100vh;
  padding: 32px 24px 60px;
  position: relative;
  z-index: 1;
  overflow-x: hidden;
  transition: color 0.25s ease;
}

html::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
}

html::after {
  content: '';
  position: fixed;
  top: -200px;
  left: 50%;
  transform: translateX(-50%);
  width: 700px;
  height: 500px;
  background: var(--bg-pattern);
  pointer-events: none;
  z-index: 0;
  transition: background 0.25s ease;
}

body > iframe {
  position: fixed !important;
  top: -9999px !important;
  left: -9999px !important;
  width: 1px !important;
  height: 1px !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

body > canvas {
  display: none !important;
}

.wrap {
  position: relative;
  z-index: 20;
  max-width: 920px;
  margin: 0 auto;
  pointer-events: auto;
}

.btn, button, a, select, input, #dropzone, .nav-menu a, .logo {
  pointer-events: auto !important;
}

/* ── Header / Navigation ────────────────────────────────────────── */
header {
  position: sticky;
  top: 16px;
  z-index: 10;
  display: block;
  margin-bottom: 28px;
  padding: 16px 24px;
  background: var(--header-bg);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  transition: all 0.25s ease;
}

.logo {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-decoration: none;
  margin-bottom: 14px;
}

.logo-name {
  font-size: 2.1rem;
  font-weight: 800;
  letter-spacing: -1.2px;
  line-height: 1;
  background: var(--logo-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: var(--logo-shadow);
  transition: all 0.25s ease;
}

.logo-sub {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--accent);
  letter-spacing: 2px;
  text-transform: uppercase;
  font-weight: 600;
  transition: color 0.25s ease;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.nav-menu {
  flex: 1 1 auto;
  display: flex;
  gap: 4px;
  align-items: center;
  flex-wrap: wrap;
  padding: 4px;
  background: var(--nav-bg);
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  transition: all 0.25s ease;
}

.nav-menu a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  transition: all 0.18s ease;
  padding: 8px 14px;
  border-radius: var(--radius-full);
  background: transparent;
}

.nav-menu a:hover {
  color: var(--text);
  background: var(--accent-subtle);
  transform: translateY(-1px);
}

.nav-menu a.active {
  color: var(--accent-text);
  font-weight: 700;
  background: var(--accent);
  box-shadow: var(--shadow-sm);
}

/* ── Theme Toggle Button ────────────────────────────────────────── */
button.theme-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-family: var(--display);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
  white-space: nowrap;
}

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

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

.theme-icon {
  font-size: 1rem;
  line-height: 1;
}

/* ── Buttons ────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 18px;
  border: none;
  border-radius: var(--radius-full);
  font-family: var(--display);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  letter-spacing: 0.2px;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
}

.btn-primary:hover {
  background: var(--accent2);
  transform: translateY(-1px);
  box-shadow: var(--accent-glow);
}

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

.btn-ghost {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border2);
}

.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-subtle);
  transform: translateY(-1px);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid transparent;
  padding: 6px 12px;
  font-size: 0.78rem;
}

.btn-danger:hover {
  border-color: var(--danger);
  background: var(--danger-bg);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.78rem;
}

.btn-download {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid var(--success);
}

.btn-download:hover {
  background: var(--success);
  color: var(--accent-text);
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* ── Content Sections ───────────────────────────────────────────── */
.content-section {
  display: none;
}

.content-section.active {
  display: block;
  animation: fadeInUp 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

.section-title {
  font-size: 2.1rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 12px;
  color: var(--title-color);
  text-shadow: var(--title-shadow);
  transition: all 0.25s ease;
}

.section-subtitle {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  margin-top: 28px;
  margin-bottom: 12px;
  letter-spacing: -0.2px;
}

.section-helper {
  color: var(--muted);
  margin-bottom: 16px;
  font-size: 0.95rem;
}

.article-intro {
  font-size: 1.05rem;
  line-height: 1.75;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.article-body {
  font-size: 0.96rem;
  line-height: 1.8;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.article-body strong {
  color: var(--text);
}

/* ── Hero & Feature Cards ───────────────────────────────────────── */
.hero-card {
  background: var(--hero-bg);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 28px;
  box-shadow: var(--shadow-md);
  margin-bottom: 22px;
  transition: all 0.25s ease;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  background: var(--accent-subtle);
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 14px;
}

.hero-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 20px;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 20px;
  margin: 20px 0 28px;
}

.feature-card {
  appearance: none;
  text-align: left;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 18px;
  min-height: 255px;
  padding: 28px 24px 22px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.feature-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
}

.feature-card strong {
  display: block;
  margin-bottom: 6px;
  color: var(--accent);
  font-size: 1.02rem;
}

.feature-card p {
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.6;
}

.tool-card {
  cursor: pointer;
}

.tool-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  margin-bottom: 26px;
  border-radius: 6px;
  color: #fff;
  font-family: var(--display);
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0;
}

.tool-icon-png {
  display: block;
  width: 48px;
  height: 48px;
  margin-bottom: 26px;
  object-fit: contain;
}

.tool-orange { background: #f06a4b; }
.tool-blue { background: #5f82c7; }
.tool-coral { background: #ff704f; }
.tool-green { background: #5da363; }
.tool-purple { background: #ae6e9b; font-size: 0.72rem; }
.tool-slate { background: #7b8496; font-size: 0.7rem; }

/* ── Dropzone & Converter ───────────────────────────────────────── */
#dropzone, #compressDropzone, .dropzone-box {
  border: 2px dashed var(--border2);
  border-radius: 22px;
  padding: 46px 28px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  background: var(--dropzone-bg);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

#dropzone:hover, #dropzone.drag-over,
#compressDropzone:hover, #compressDropzone.drag-over,
.dropzone-box:hover, .dropzone-box.drag-over {
  border-color: var(--accent);
  background: var(--accent-subtle);
  transform: translateY(-2px);
}

.preset-btn {
  transition: all 0.2s ease;
}

.preset-btn.active {
  background: var(--accent) !important;
  color: var(--accent-text) !important;
  border-color: var(--accent) !important;
  font-weight: 700;
}

.dropzone-icon {
  font-size: 2.8rem;
  margin-bottom: 12px;
}

.dropzone-title {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--text);
}

.dropzone-desc {
  font-size: 0.86rem;
  color: var(--muted);
}

.file-list {
  list-style: none;
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.file-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s ease, transform 0.2s ease;
}

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

.file-icon {
  font-size: 1.8rem;
  flex-shrink: 0;
}

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

.file-name {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 4px;
  word-break: break-all;
  color: var(--text);
}

.file-meta {
  display: flex;
  gap: 12px;
  font-size: 0.78rem;
  color: var(--muted);
  flex-wrap: wrap;
  align-items: center;
}

.file-savings {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--success-bg);
  color: var(--success);
  font-weight: 700;
  font-size: 0.72rem;
}

.file-target {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.file-target select {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border2);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-family: var(--display);
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s ease;
}

.file-target select:focus {
  border-color: var(--accent);
}

.file-status {
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  white-space: nowrap;
}

.file-status.ready {
  background: var(--surface2);
  color: var(--muted);
}

.file-status.converting {
  background: var(--warn-bg);
  color: var(--warn);
}

.file-status.done {
  background: var(--success-bg);
  color: var(--success);
}

.file-status.error {
  background: var(--danger-bg);
  color: var(--danger);
}

.file-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

.empty-state {
  padding: 28px;
  border: 1px dashed var(--border2);
  border-radius: 16px;
  color: var(--muted);
  text-align: center;
  background: var(--surface);
  font-size: 0.92rem;
}

.action-bar {
  display: flex;
  gap: 12px;
  margin-top: 20px;
  flex-wrap: wrap;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--action-bar-bg);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

/* ── Toast ──────────────────────────────────────────────────────── */
#toast {
  position: fixed;
  top: 24px;
  right: 24px;
  background: var(--toast-bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 18px;
  border-radius: 14px;
  z-index: 999;
  opacity: 0;
  transform: translateY(-10px);
  pointer-events: none;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: var(--shadow-md);
  font-weight: 500;
  font-size: 0.88rem;
}

#toast.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* ── Footer ─────────────────────────────────────────────────────── */
.footer {
  margin-top: 56px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--muted);
  text-align: center;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.footer-links a {
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s ease;
}

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

/* ── Animations ─────────────────────────────────────────────────── */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Responsive Breakpoints ─────────────────────────────────────── */
@media (max-width: 760px) {
  .feature-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  body {
    padding: 16px 14px 40px;
  }
  
  header {
    padding: 14px 16px;
    margin-bottom: 20px;
    border-radius: 18px;
  }
  
  .logo-name {
    font-size: 1.8rem;
  }
  
  .header-right {
    width: 100%;
    justify-content: space-between;
    align-items: flex-start;
  }
  
  .nav-menu {
    min-width: 0;
    gap: 2px;
    font-size: 0.82rem;
    overflow-x: auto;
  }
  
  .nav-menu a {
    padding: 6px 10px;
    font-size: 0.8rem;
  }
  
  #dropzone {
    padding: 32px 18px;
  }
  
  .section-title {
    font-size: 1.6rem;
  }
  
  .file-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  
  .file-actions {
    width: 100%;
    justify-content: flex-end;
  }
  
  .action-bar {
    padding: 12px;
  }
}
