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

:root {
  --primary: #2563EB;
  --primary-hover: #1D4ED8;
  --primary-light: #DBEAFE;
  --success: #10B981;
  --bg: #F8FAFC;
  --card: #FFFFFF;
  --text: #0F172A;
  --text-secondary: #64748B;
  --border: #E2E8F0;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-hover: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
  --radius: 12px;
  --radius-sm: 8px;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

img {
  max-width: 100%;
  height: auto;
}

.container {
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 12px;
}

/* === Header / Nav === */
.site-header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.logo {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
}

.logo:hover {
  text-decoration: none;
  opacity: 0.9;
}

.main-nav {
  display: flex;
  gap: 4px;
}

.main-nav a {
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  transition: background 0.2s, color 0.2s;
  white-space: nowrap;
  cursor: pointer;
}

.main-nav a:hover {
  background: var(--primary-light);
  color: var(--primary);
  text-decoration: none;
}

.lang-switch {
  margin-left: 8px;
}

/* === Hero Section === */
.hero {
  text-align: center;
  padding: 36px 12px 24px;
}

.hero h1 {
  font-size: 2.2rem;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 16px;
  color: var(--text);
}

.hero p {
  font-size: 1.1rem;
  color: var(--text-secondary);
  max-width: 600px;
  margin: 0 auto;
}

/* === Tool Grid === */
.tool-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  padding: 16px 0 24px;
}

.tool-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 16px;
  box-shadow: var(--shadow);
  transition: box-shadow 0.25s, transform 0.25s;
  text-decoration: none;
  color: var(--text);
  display: block;
}

.tool-card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
  text-decoration: none;
  color: var(--text);
}

.tool-card .icon {
  font-size: 2.4rem;
  margin-bottom: 12px;
  display: block;
}

.tool-card h2 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.tool-card p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* === Privacy Promise === */
.privacy-promise {
  background: var(--primary-light);
  border-radius: var(--radius);
  padding: 24px 16px;
  text-align: center;
  margin: 16px 0 32px;
}

.privacy-promise h2 {
  font-size: 1.3rem;
  color: var(--primary);
  margin-bottom: 8px;
}

.privacy-promise p {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

/* === Footer === */
.site-footer {
  background: var(--card);
  border-top: 1px solid var(--border);
  padding: 24px 0;
  margin-top: auto;
  text-align: center;
}

.site-footer p {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.footer-links {
  margin-top: 8px;
}

.footer-links a {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin: 0 8px;
}

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

/* === Tool Page Specific === */
.tool-page {
  padding: 20px 0 32px;
}

.tool-page h1 {
  font-size: 1.8rem;
  font-weight: 800;
  margin-bottom: 10px;
  text-align: center;
}

.tool-description {
  text-align: center;
  color: var(--text-secondary);
  font-size: 1rem;
  max-width: 650px;
  margin: 0 auto 28px;
}

/* === Upload Area === */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.25s, background 0.25s;
  max-width: 560px;
  margin: 0 auto;
  background: var(--card);
}

.upload-area:hover {
  border-color: var(--primary);
}

.upload-area.dragover {
  border-style: solid;
  border-color: var(--primary);
  background: var(--primary-light);
}

.upload-area .upload-icon {
  font-size: 3rem;
  margin-bottom: 12px;
  display: block;
}

.upload-area p {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.upload-area .upload-btn {
  display: inline-block;
  margin-top: 12px;
  padding: 10px 24px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
  min-height: 44px;
}

.upload-area .upload-btn:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

/* === Tool Controls === */
.tool-controls {
  max-width: 520px;
  margin: 16px auto 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.control-group {
  margin-bottom: 18px;
}

.control-group:last-child {
  margin-bottom: 0;
}

.control-group label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

.control-group .hint {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 400;
  margin-left: 4px;
}

.control-group input[type="range"] {
  width: 100%;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--border);
  border-radius: 3px;
  outline: none;
}

.control-group input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.control-group input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.control-group input[type="number"],
.control-group select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
  background: var(--card);
  color: var(--text);
}

.control-group input[type="number"]:focus,
.control-group select:focus {
  border-color: var(--primary);
}

.control-row {
  display: flex;
  gap: 12px;
}

.control-row .control-group {
  flex: 1;
}

.range-value {
  font-weight: 700;
  color: var(--primary);
}

.btn {
  display: inline-block;
  padding: 12px 28px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
  min-height: 48px;
}

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

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-success {
  background: var(--success);
}

.btn-success:hover {
  background: #059669;
}

.btn-block {
  width: 100%;
}

/* === Preview === */
.preview-section {
  margin-top: 20px;
}

.preview-section h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 12px;
  text-align: center;
}

.preview-comparison {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.preview-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  flex: 1;
}

.preview-box .label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
  display: block;
}

.preview-box .size-info {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 6px;
}

.preview-box img {
  max-width: 100%;
  max-height: 350px;
  border-radius: 4px;
  display: block;
  margin: 0 auto;
}

.compression-info {
  text-align: center;
  margin-top: 12px;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.compression-info .saved {
  color: var(--success);
  font-weight: 700;
}

/* === How To Use / FAQ === */
.section-block {
  max-width: 560px;
  margin: 24px auto 0;
}

.section-block h2 {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text);
}

.how-to-steps {
  list-style: none;
  padding: 0;
}

.how-to-steps li {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
  color: var(--text-secondary);
  font-size: 0.92rem;
}

.how-to-steps li .step-num {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
}

/* === FAQ === */
.faq-item {
  border-bottom: 1px solid var(--border);
  padding: 16px 0;
}

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

.faq-item h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

.faq-item p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* === Related Tools === */
.related-tools {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.related-tools h2 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 14px;
  text-align: center;
}

.related-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.related-links a {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  color: var(--primary);
  transition: background 0.2s, border-color 0.2s;
  text-decoration: none;
}

.related-links a:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  text-decoration: none;
}

/* === Preset Buttons === */
.preset-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.preset-btn {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text);
}

.preset-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.preset-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* === Lock Button === */
.lock-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text);
  min-height: 40px;
}

.lock-btn:hover {
  border-color: var(--primary);
}

.lock-btn.locked {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

/* === Crop Info === */
.crop-info {
  font-size: 0.88rem;
  color: var(--text-secondary);
  text-align: center;
  margin-top: 8px;
}

/* === About / Privacy Pages === */
.content-page {
  padding: 28px 12px;
  max-width: 600px;
  margin: 0 auto;
}

.content-page h1 {
  font-size: 1.6rem;
  font-weight: 800;
  margin-bottom: 16px;
}

.content-page h2 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-top: 20px;
  margin-bottom: 8px;
}

.content-page p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 10px;
  line-height: 1.6;
}
  line-height: 1.7;
}

.content-page ul {
  margin: 10px 0 14px 20px;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.content-page ul li {
  margin-bottom: 6px;
}

/* === Responsive Navigation === */
@media (max-width: 768px) {
  .header-inner {
    flex-wrap: wrap;
    height: auto;
    padding: 12px 0;
    gap: 10px;
  }

  .logo {
    flex: 1;
  }

  .main-nav {
    width: 100%;
    justify-content: flex-start;
    gap: 2px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
  }

  .main-nav a {
    font-size: 0.8rem;
    padding: 6px 10px;
  }

  .footer-links a {
    display: inline-block;
    margin: 4px 8px 4px 0;
  }
}

/* === Responsive Layouts === */
@media (min-width: 640px) {
  .tool-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .preview-comparison {
    flex-direction: row;
  }

  .hero h1 {
    font-size: 2.2rem;
  }
}

@media (min-width: 1024px) {
  .hero h1 {
    font-size: 2.4rem;
  }

  .hero {
    padding: 48px 20px 32px;
  }

  .tool-grid {
    gap: 24px;
  }
}

/* === Overlay Mask === */
.overlay-mask {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 10, 10, 0.98);
  z-index: 1000;
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.overlay-mask.active {
  display: flex;
}

.overlay-header {
  background: #1a1a1a;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.overlay-header h2 {
  color: #fff;
  font-size: 1rem;
  margin: 0;
}

.overlay-canvas-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 30px;
  padding: 20px;
  overflow: hidden;
}

.overlay-preview-box {
  background: #000;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  max-width: 45%;
  max-height: 100%;
}

.overlay-preview-box img {
  max-width: 100%;
  max-height: 55vh;
  object-fit: contain;
}

.overlay-preview-box .label {
  color: #888;
  font-size: 0.85rem;
  margin-bottom: 8px;
}

.overlay-preview-box .size-info {
  color: #666;
  font-size: 0.8rem;
  margin-top: 8px;
}

.overlay-footer {
  background: #1a1a1a;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.overlay-btn-close {
  background: #333;
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
}

.overlay-btn-close:hover {
  background: #444;
}

/* Crop specific overlay */
.crop-overlay-canvas {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  overflow: auto;
}

.crop-overlay-canvas canvas {
  max-width: 100%;
  max-height: 55vh;
  cursor: crosshair;
}

.crop-overlay-handles {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

/* Responsive overlays */
@media (max-width: 768px) {
  .overlay-canvas-area {
    flex-direction: column;
    gap: 20px;
  }
  
  .overlay-preview-box {
    max-width: 90%;
    flex: none;
  }
  
  .overlay-footer {
    flex-direction: column;
    gap: 12px;
  }
}
