/* ===== CSS Variables ===== */
:root {
  --bg: #ffffff;
  --bg-secondary: #f8f8fc;
  --surface: #f1f1f8;
  --border: #e2e2f0;
  --text: #1a1a2e;
  --text-secondary: #6b7280;
  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --accent-light: #eef2ff;
  --success: #10b981;
  --warning: #f59e0b;
  --error: #ef4444;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.06);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.10);
  --transition: 0.2s ease;
}

[data-theme="dark"] {
  --bg: #0f0f17;
  --bg-secondary: #1a1a27;
  --surface: #252535;
  --border: #353550;
  --text: #f0f0ff;
  --text-secondary: #9d9db8;
  --accent: #818cf8;
  --accent-hover: #6366f1;
  --accent-light: #1e1e35;
  --shadow: 0 1px 3px rgba(0,0,0,.3), 0 4px 12px rgba(0,0,0,.25);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.4);
}

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

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

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

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

img, video { max-width: 100%; display: block; }

/* ===== Layout ===== */
.container { max-width: 900px; margin: 0 auto; padding: 0 20px; }
.container--wide { max-width: 1200px; margin: 0 auto; padding: 0 20px; }

main { flex: 1; }

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

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

.logo {
  font-weight: 800;
  font-size: 1.2rem;
  color: var(--text);
  letter-spacing: -.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.logo span { color: var(--accent); }
.logo:hover { text-decoration: none; }

.nav-tools {
  display: flex;
  gap: 4px;
  align-items: center;
  overflow-x: auto;
  scrollbar-width: none;
}
.nav-tools::-webkit-scrollbar { display: none; }

.nav-tools a {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  transition: background var(--transition), color var(--transition);
}
.nav-tools a:hover, .nav-tools a.active {
  background: var(--accent-light);
  color: var(--accent);
  text-decoration: none;
}

.header-actions { display: flex; align-items: center; gap: 8px; }

/* ===== Dark Mode Toggle ===== */
.theme-toggle {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: background var(--transition);
  flex-shrink: 0;
}
.theme-toggle:hover { background: var(--accent-light); }

/* ===== AdSense Slot — Header below ===== */
.ad-slot-header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 0.75rem;
  /* Placeholder — AdSense code goes here after approval */
}

/* ===== Hero (index only) ===== */
.hero {
  padding: 64px 0 48px;
  text-align: center;
}
.hero h1 {
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  font-weight: 800;
  letter-spacing: -.5px;
  line-height: 1.2;
  margin-bottom: 16px;
}
.hero h1 em { color: var(--accent); font-style: normal; }
.hero p {
  font-size: 1.1rem;
  color: var(--text-secondary);
  max-width: 560px;
  margin: 0 auto 32px;
}

/* ===== Tool Cards Grid (index) ===== */
.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  padding-bottom: 64px;
}

.tool-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: box-shadow var(--transition), transform var(--transition), border-color var(--transition);
  cursor: pointer;
}
.tool-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
  border-color: var(--accent);
  text-decoration: none;
}
.tool-card-icon { font-size: 1.8rem; }
.tool-card-title { font-weight: 700; font-size: 1rem; color: var(--text); }
.tool-card-desc { font-size: 0.82rem; color: var(--text-secondary); }
.tool-card-badge {
  align-self: flex-start;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--accent-light);
  color: var(--accent);
}

/* ===== Tool Page Layout ===== */
.tool-page { padding: 40px 0 64px; }

.tool-header { margin-bottom: 32px; }
.tool-header h1 { font-size: 1.8rem; font-weight: 800; letter-spacing: -.5px; }
.tool-header p { color: var(--text-secondary); margin-top: 6px; }

/* ===== File Drop Zone ===== */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  background: var(--bg-secondary);
  position: relative;
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-light);
}
.drop-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}
.drop-zone-icon { font-size: 2.5rem; margin-bottom: 12px; }
.drop-zone-title { font-weight: 700; font-size: 1rem; margin-bottom: 4px; }
.drop-zone-desc { font-size: 0.85rem; color: var(--text-secondary); }

.source-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
  color: var(--text-secondary);
  font-size: 0.82rem;
}
.source-divider::before, .source-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.url-input-wrap { display: flex; gap: 8px; }
.url-input-wrap input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
  transition: border-color var(--transition);
}
.url-input-wrap input:focus { border-color: var(--accent); }
.url-input-wrap input::placeholder { color: var(--text-secondary); }

/* ===== Source Preview ===== */
.source-preview {
  display: none;
  margin-top: 24px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.source-preview.visible { display: block; }

.preview-video-wrap { background: #000; }
.preview-video-wrap video {
  width: 100%;
  max-height: 360px;
  object-fit: contain;
}

.source-meta {
  padding: 12px 16px;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 0.82rem;
  color: var(--text-secondary);
}
.source-meta strong { color: var(--text); }

.source-actions {
  padding: 0 16px 12px;
  display: flex;
  gap: 8px;
}

/* ===== Tool Options Panel ===== */
.tool-options {
  display: none;
  margin-top: 24px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}
.tool-options.visible { display: block; }
.tool-options h2 { font-size: 1rem; font-weight: 700; margin-bottom: 20px; }

.options-grid {
  display: grid;
  gap: 20px;
}

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: 0.85rem; font-weight: 600; color: var(--text); }
.form-hint { font-size: 0.78rem; color: var(--text-secondary); }

.form-select, .form-input {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
  transition: border-color var(--transition);
}
.form-select:focus, .form-input:focus { border-color: var(--accent); }

/* ===== Trim Slider ===== */
.trim-slider-wrap {
  position: relative;
  margin: 8px 0 16px;
}

.trim-time-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}
.trim-time-group { display: flex; flex-direction: column; gap: 4px; }
.trim-time-group label { font-size: 0.78rem; font-weight: 600; color: var(--text-secondary); }
.trim-time-group input {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
  font-family: monospace;
  outline: none;
}
.trim-time-group input:focus { border-color: var(--accent); }

.range-track {
  position: relative;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  margin: 18px 0;
}
.range-fill {
  position: absolute;
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  pointer-events: none;
}
.range-handle {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 20px;
  height: 20px;
  background: var(--accent);
  border: 3px solid var(--bg);
  border-radius: 50%;
  cursor: grab;
  box-shadow: var(--shadow);
  z-index: 2;
  transition: box-shadow var(--transition);
}
.range-handle:hover, .range-handle:active { box-shadow: 0 0 0 4px var(--accent-light); cursor: grabbing; }

/* ===== Preset Buttons ===== */
.preset-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.preset-btn {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}
.preset-btn:hover, .preset-btn.active {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
}

/* ===== Progress ===== */
.progress-wrap {
  display: none;
  margin-top: 24px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}
.progress-wrap.visible { display: block; }

.progress-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.progress-title { font-weight: 700; font-size: 0.95rem; }
.progress-pct { font-size: 0.85rem; color: var(--text-secondary); font-variant-numeric: tabular-nums; }

.progress-bar {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 12px;
}
.progress-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.3s ease;
  width: 0%;
}

.progress-status { font-size: 0.82rem; color: var(--text-secondary); }

/* ===== Result Panel ===== */
.result-panel {
  display: none;
  margin-top: 24px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.result-panel.visible { display: block; }

.result-preview-wrap { background: #000; }
.result-preview-wrap video, .result-preview-wrap img, .result-preview-wrap audio {
  width: 100%;
  max-height: 360px;
  object-fit: contain;
}
.result-preview-wrap audio { background: var(--surface); padding: 20px; }

.result-actions {
  padding: 16px;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.filename-edit-wrap { display: flex; gap: 8px; align-items: center; flex: 1; min-width: 200px; }
.filename-edit-wrap input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 0.85rem;
  outline: none;
}
.filename-edit-wrap input:focus { border-color: var(--accent); }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition), opacity var(--transition);
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border); }

.btn-danger { background: var(--error); color: #fff; }
.btn-success { background: var(--success); color: #fff; }

.btn-sm { padding: 6px 14px; font-size: 0.82rem; }
.btn-lg { padding: 13px 28px; font-size: 1rem; }
.btn-full { width: 100%; }

/* ===== Alerts ===== */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-top: 12px;
}
.alert-warning { background: #fff7ed; color: #92400e; border: 1px solid #fed7aa; }
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-info { background: var(--accent-light); color: var(--accent); border: 1px solid #c7d2fe; }
[data-theme="dark"] .alert-warning { background: #3b2000; color: #fbbf24; border-color: #92400e; }
[data-theme="dark"] .alert-error { background: #3b0000; color: #f87171; border-color: #991b1b; }

/* ===== Ad Slot (sidebar / inline) ===== */
.ad-slot-side {
  min-height: 250px;
  min-width: 160px;
  background: var(--bg-secondary);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 0.75rem;
  /* Placeholder for AdSense */
}
.ad-slot-inline {
  min-height: 90px;
  background: var(--bg-secondary);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 0.75rem;
  margin: 32px 0;
}

/* ===== Tool Page Two-Column ===== */
.tool-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}
@media (min-width: 900px) {
  .tool-layout {
    grid-template-columns: 1fr 200px;
    align-items: start;
  }
}

/* ===== Content Section (SEO / How-to) ===== */
.content-section {
  margin-top: 48px;
  padding-top: 40px;
  border-top: 1px solid var(--border);
}
.content-section h2 { font-size: 1.3rem; font-weight: 700; margin-bottom: 12px; }
.content-section h3 { font-size: 1rem; font-weight: 700; margin: 20px 0 8px; color: var(--text); }
.content-section p { color: var(--text-secondary); font-size: 0.9rem; line-height: 1.75; margin-bottom: 12px; }
.content-section ol, .content-section ul { padding-left: 20px; color: var(--text-secondary); font-size: 0.9rem; line-height: 1.75; }
.content-section li { margin-bottom: 6px; }

.faq-item { border-bottom: 1px solid var(--border); padding: 14px 0; }
.faq-question { font-weight: 600; color: var(--text); margin-bottom: 6px; font-size: 0.9rem; }
.faq-answer { color: var(--text-secondary); font-size: 0.85rem; line-height: 1.7; }

/* ===== Footer ===== */
.site-footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  padding: 32px 0;
  margin-top: auto;
}
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  align-items: center;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--text-secondary);
}
.footer-links { display: flex; gap: 16px; flex-wrap: wrap; }
.footer-links a { color: var(--text-secondary); }
.footer-links a:hover { color: var(--accent); }

/* ===== Static Pages (about, privacy, terms, contact) ===== */
.static-page { padding: 48px 0 64px; }
.static-page h1 { font-size: 1.8rem; font-weight: 800; margin-bottom: 8px; }
.static-page .subtitle { color: var(--text-secondary); margin-bottom: 40px; }
.static-page h2 { font-size: 1.1rem; font-weight: 700; margin: 32px 0 10px; }
.static-page p { color: var(--text-secondary); line-height: 1.8; margin-bottom: 12px; }
.static-page ul { padding-left: 20px; color: var(--text-secondary); line-height: 1.8; }
.static-page li { margin-bottom: 6px; }

/* ===== Contact Form ===== */
.contact-form { display: flex; flex-direction: column; gap: 16px; max-width: 560px; }
.contact-form input, .contact-form textarea, .contact-form select {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition);
}
.contact-form input:focus, .contact-form textarea:focus { border-color: var(--accent); }
.contact-form textarea { min-height: 140px; resize: vertical; }

/* ===== Responsive ===== */
@media (max-width: 640px) {
  .nav-tools { display: none; }
  .hero { padding: 40px 0 32px; }
  .tool-page { padding: 24px 0 48px; }
  .tool-options { padding: 16px; }
  .drop-zone { padding: 32px 16px; }
  .trim-time-inputs { grid-template-columns: 1fr 1fr; }
  .result-actions { flex-direction: column; align-items: stretch; }
  .footer-inner { flex-direction: column; align-items: flex-start; }
}

/* ===== Utilities ===== */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.text-center { text-align: center; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-4 { margin-bottom: 4px; }
.hidden { display: none !important; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
