* { box-sizing: border-box; }

:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --violet: #8b5cf6;
  --violet-deep: #7c3aed;
  --accent: #6366f1;
  --accent-dark: #5b21b6;
  --gradient: linear-gradient(135deg, #6366f1 0%, #7c3aed 55%, #a78bfa 100%);
  --gradient-hover: linear-gradient(135deg, #4f46e5 0%, #6d28d9 55%, #8b5cf6 100%);
  --gradient-soft: linear-gradient(145deg, #eef2ff 0%, #f5f3ff 45%, #ede9fe 100%);
  --gradient-page: linear-gradient(
    165deg,
    #f0f4ff 0%,
    #f5f3ff 30%,
    #ede9fe 65%,
    #e8e4ff 100%
  );
  --text: #1e1b4b;
  --muted: #5c5678;
  --card: rgba(255, 255, 255, 0.88);
  --card-solid: #ffffff;
  --border: rgba(99, 102, 241, 0.18);
  --shadow: 0 4px 24px rgba(99, 102, 241, 0.1);
  --shadow-sm: 0 2px 12px rgba(124, 58, 237, 0.08);
  --glow: rgba(99, 102, 241, 0.35);
  --success: #059669;
  --error: #dc2626;
}

body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  max-width: 900px;
  margin: 0 auto;
  padding: 20px;
  min-height: 100vh;
  background: var(--gradient-page);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.5;
}

a {
  color: var(--primary-dark);
  transition: color 0.2s;
}

a:hover {
  color: var(--violet-deep);
}

.text-muted-sm {
  font-size: 0.8rem;
  color: var(--muted);
}

/* —— Header —— */
.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 2rem;
  padding: 14px 18px;
  background: var(--card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
}

.header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 0 0 auto;
  min-width: 0;
  gap: 12px;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
  text-decoration: none;
  transition: opacity 0.2s;
}

.logo:hover {
  color: var(--text);
  opacity: 0.88;
}

.logo-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  font-size: 1.2rem;
  line-height: 1;
  background: var(--gradient);
  border-radius: 10px;
  border: none;
  box-shadow: 0 2px 8px var(--glow);
}

.logo-text {
  letter-spacing: -0.02em;
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  margin-left: auto;
}

.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--gradient-soft);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s, box-shadow 0.2s, border-color 0.2s;
}

.nav-toggle:hover {
  border-color: rgba(124, 58, 237, 0.35);
  box-shadow: 0 2px 10px rgba(99, 102, 241, 0.15);
}

.nav-toggle-box {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 18px;
  height: 14px;
}

.nav-toggle-line {
  display: block;
  width: 100%;
  height: 2px;
  border-radius: 2px;
  background: var(--gradient);
  transition: transform 0.25s ease, opacity 0.2s ease;
}

.nav-toggle[aria-expanded='true'] .nav-toggle-line:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.nav-toggle[aria-expanded='true'] .nav-toggle-line:nth-child(2) {
  opacity: 0;
}

.nav-toggle[aria-expanded='true'] .nav-toggle-line:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

.site-nav a.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  color: var(--muted);
  border-radius: 999px;
  border: 1px solid transparent;
  transition: background 0.2s, color 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.nav-emoji {
  font-size: 1rem;
  line-height: 1;
}

.site-nav a.nav-link:hover {
  color: var(--violet-deep);
  background: rgba(237, 233, 254, 0.8);
  border-color: rgba(139, 92, 246, 0.2);
}

.site-nav a.nav-link.active {
  color: var(--accent-dark);
  background: var(--gradient-soft);
  border-color: rgba(124, 58, 237, 0.28);
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.12);
}

/* —— Typography —— */
h1 {
  font-size: 1.8rem;
  text-align: center;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.page-title {
  font-size: 1.6rem;
  margin-bottom: 1rem;
  color: var(--text);
}

.sub {
  text-align: center;
  color: var(--muted);
  margin-bottom: 2rem;
}

.badge {
  display: inline-block;
  font-size: 0.75rem;
  background: var(--gradient-soft);
  color: var(--accent-dark);
  padding: 4px 12px;
  border-radius: 20px;
  margin-left: 6px;
  vertical-align: middle;
  border: 1px solid var(--border);
  font-weight: 600;
}

/* —— Upload —— */
.upload-area {
  border: 2px dashed rgba(139, 92, 246, 0.35);
  border-radius: 24px;
  background: var(--card);
  backdrop-filter: blur(8px);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.25s ease;
  box-shadow: var(--shadow-sm);
}

.upload-area:hover {
  border-color: rgba(99, 102, 241, 0.5);
  box-shadow: var(--shadow);
}

.upload-area.drag-over {
  border-color: var(--violet);
  background: linear-gradient(145deg, rgba(238, 242, 255, 0.95) 0%, rgba(237, 233, 254, 0.95) 100%);
  box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.15);
}

.upload-icon { font-size: 48px; margin-bottom: 12px; }
.file-input { display: none; }

/* —— Buttons —— */
.btn {
  background: var(--gradient);
  color: white;
  border: none;
  border-radius: 40px;
  padding: 10px 24px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.2s, filter 0.2s;
  box-shadow: 0 4px 14px var(--glow);
}

.btn:hover {
  background: var(--gradient-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(124, 58, 237, 0.4);
}

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

.btn-sm {
  padding: 8px 16px;
  font-size: 0.85rem;
  border-radius: 24px;
  white-space: nowrap;
}

/* —— Cards & results —— */
.result-card {
  background: var(--card);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px;
  margin-top: 32px;
  box-shadow: var(--shadow);
}

.flex-row {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  justify-content: space-between;
}

.preview-box { flex: 1; text-align: center; min-width: 200px; }

.preview-img {
  max-width: 100%;
  max-height: 300px;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.12);
}

.info {
  font-size: 0.9rem;
  color: var(--muted);
  margin: 12px 0;
}

.size-summary {
  font-weight: 600;
  font-size: 1rem;
  color: var(--accent-dark);
  margin: 8px 0 16px;
}

.saving {
  color: var(--violet-deep);
  font-weight: bold;
}

.progress-bar {
  width: 100%;
  height: 8px;
  background: rgba(99, 102, 241, 0.12);
  border-radius: 10px;
  margin: 16px 0;
  overflow: hidden;
}

.progress-fill {
  width: 0%;
  height: 100%;
  background: var(--gradient);
  border-radius: 10px;
  transition: width 0.2s;
}

/* —— Controls —— */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  justify-content: center;
  margin-top: 16px;
  font-size: 0.9rem;
  padding: 14px 18px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  backdrop-filter: blur(8px);
}

.controls label { display: flex; align-items: center; gap: 8px; }

.controls input[type='range'] {
  accent-color: var(--violet);
}

.format-options {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  justify-content: center;
  margin-top: 12px;
}

.format-options label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.85rem;
  cursor: pointer;
  text-align: left;
  max-width: 280px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid transparent;
  transition: background 0.2s, border-color 0.2s;
}

.format-options label:has(input:checked) {
  background: var(--gradient-soft);
  border-color: rgba(124, 58, 237, 0.25);
}

.format-options input {
  margin-top: 3px;
  accent-color: var(--violet);
}

.format-hint {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: normal;
  margin-top: 2px;
}

.controls .quality-label-text {
  white-space: nowrap;
}

.hint-box {
  background: var(--gradient-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 16px;
  text-align: center;
}

/* —— Footer —— */
.site-footer {
  text-align: center;
  margin-top: 48px;
  font-size: 0.8rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  padding-top: 24px;
}

.site-footer a {
  color: var(--primary-dark);
}

/* —— Prose pages —— */
.prose h2 {
  font-size: 1.15rem;
  margin-top: 1.5rem;
  color: var(--text);
}

.prose h3 {
  font-size: 1rem;
  margin-top: 1.25rem;
  color: var(--violet-deep);
}

.prose ul { padding-left: 1.25rem; }
.prose li { margin: 0.5rem 0; }

.prose code {
  font-size: 0.9em;
  background: rgba(237, 233, 254, 0.9);
  color: var(--accent-dark);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.article-meta {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.cta-box {
  background: var(--gradient-soft);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px 24px;
  margin: 1.5rem 0;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.cta-box .btn {
  display: inline-block;
  text-decoration: none;
  margin-top: 8px;
}

.steps {
  counter-reset: step;
  list-style: none;
  padding: 0;
}

.steps li {
  counter-increment: step;
  margin: 1rem 0;
  padding-left: 2.5rem;
  position: relative;
}

.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  width: 1.75rem;
  height: 1.75rem;
  background: var(--gradient);
  color: white;
  border-radius: 50%;
  text-align: center;
  line-height: 1.75rem;
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: 0 2px 8px var(--glow);
}

/* —— Batch list —— */
.batch-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.batch-toolbar .size-summary {
  margin: 0;
  flex: 1;
  min-width: 200px;
}

.batch-status-msg {
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 16px;
}

.batch-status-warn {
  color: #b45309;
}

.batch-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.batch-item {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.6);
  transition: box-shadow 0.2s;
}

.batch-item:hover {
  box-shadow: var(--shadow-sm);
}

.batch-thumb {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 8px;
  background: rgba(237, 233, 254, 0.8);
}

.batch-meta {
  min-width: 0;
}

.batch-name {
  font-weight: 600;
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.batch-sizes {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 4px 0 8px;
}

.batch-item-progress {
  height: 4px;
  background: rgba(99, 102, 241, 0.12);
  border-radius: 4px;
  overflow: hidden;
}

.batch-item-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--gradient);
  transition: width 0.2s;
}

.batch-item-status {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 4px;
}

.status-done { color: var(--success); }
.status-error { color: var(--error); }
.status-processing { color: var(--violet-deep); }

/* —— SEO: breadcrumbs, FAQ, intro —— */
.breadcrumbs {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 1.25rem;
}

.breadcrumbs ol {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.breadcrumbs li + li::before {
  content: '›';
  margin-right: 6px;
  color: rgba(99, 102, 241, 0.45);
}

.breadcrumbs a {
  text-decoration: none;
}

.seo-intro,
.faq-section {
  margin-top: 2.5rem;
  padding: 24px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow-sm);
}

.faq-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.faq-list details {
  border-bottom: 1px solid var(--border);
  padding: 12px 0;
}

.faq-list details:last-child {
  border-bottom: none;
}

.faq-list summary {
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
  list-style: none;
}

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

.faq-list summary::before {
  content: '＋ ';
  color: var(--violet);
  font-weight: 700;
}

.faq-list details[open] summary::before {
  content: '－ ';
}

.faq-list p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.article-list {
  list-style: none;
  padding: 0;
  margin: 1.5rem 0;
}

.article-list > li {
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--border);
}

.article-list > li:last-child {
  border-bottom: none;
}

.article-list h2 {
  font-size: 1.15rem;
  margin: 0;
}

.article-list h2 a {
  text-decoration: none;
}

.article-list h2 a:hover {
  color: var(--violet);
}

.related-posts {
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.95rem;
}

.compare-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  margin: 1rem 0 1.5rem;
}

.compare-table th,
.compare-table td {
  border: 1px solid var(--border);
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
}

.compare-table thead th {
  background: rgba(99, 102, 241, 0.08);
  font-weight: 600;
}

.compare-table tbody tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.4);
}

@media (max-width: 640px) {
  .compare-table {
    font-size: 0.8rem;
  }
  .compare-table th,
  .compare-table td {
    padding: 8px;
  }
}

@media (max-width: 768px) {
  .site-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 12px 14px;
  }

  .header-bar {
    width: 100%;
  }

  .nav-toggle {
    display: inline-flex;
  }

  .site-nav {
    display: none;
    margin-left: 0;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    gap: 4px;
  }

  .site-nav.is-open {
    display: flex;
  }

  .site-nav a.nav-link {
    justify-content: flex-start;
    padding: 12px 14px;
    font-size: 0.9rem;
    border-radius: 12px;
  }
}

@media (max-width: 640px) {
  .flex-row { flex-direction: column; }
  .batch-item {
    grid-template-columns: 56px 1fr;
  }
  .batch-download {
    grid-column: 1 / -1;
    justify-self: start;
  }
}
