/* ── Variables ─────────────────────────────────────────────── */
:root {
  --primary: #C85A38;        /* Terracotta — CTAs / accent */
  --primary-hover: #a84a2d;
  --amber: #C8841A;          /* Amber — brand primary */
  --text: #1A2E3D;           /* Deep Slate */
  --text-muted: #5a7080;
  --bg: #FAF5EB;             /* Warm Cream */
  --bg-alt: #f0e8d8;
  --surface: #ffffff;
  --border: #ddd0b8;
  --error: #dc2626;
  --error-bg: #fef2f2;
  --error-border: #fca5a5;
  --success: #16a34a;
  --success-bg: #f0fdf4;
  --success-border: #86efac;
  --hero-bg: #1A2E3D;        /* Deep Slate */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,.1), 0 2px 4px rgba(0,0,0,.05);
  --shadow-lg: 0 10px 30px rgba(0,0,0,.12), 0 4px 8px rgba(0,0,0,.05);
  --nav-h: 60px;
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html {
  scroll-behavior: smooth;
  scroll-padding-top: var(--nav-h);
  font-size: 16px;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
ul { list-style: none; }
button { cursor: pointer; font-family: inherit; border: none; background: none; }
input, textarea, button, select { font-size: inherit; font-family: inherit; }

/* ── Typography ────────────────────────────────────────────── */
h1 { font-size: clamp(2rem, 5vw, 3rem); font-weight: 800; line-height: 1.15; }
h2 { font-size: clamp(1.5rem, 3vw, 2rem); font-weight: 700; }
h3 { font-size: 1.125rem; font-weight: 600; }

/* ── Layout ────────────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.25rem;
}
.container--sm { max-width: 640px; }
.section { padding: 5rem 0; }
.section-alt { background: var(--bg-alt); }
.section-header {
  text-align: center;
  margin-bottom: 3rem;
}
.section-header p {
  color: var(--text-muted);
  margin-top: .5rem;
  font-size: 1.0625rem;
}
.w-full { width: 100%; }

/* ── Navbar ────────────────────────────────────────────────── */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--hero-bg);
  height: var(--nav-h);
  transition: box-shadow .2s;
}
.navbar.scrolled { box-shadow: 0 2px 16px rgba(0,0,0,.3); }
.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.25rem;
}
.nav-logo {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--amber);
  letter-spacing: -.01em;
}
.nav-links {
  display: flex;
  gap: 2rem;
}
.nav-link {
  color: rgba(255,255,255,.7);
  font-size: .9375rem;
  font-weight: 500;
  transition: color .15s;
}
.nav-link:hover { color: #fff; }
.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  padding: 4px;
}
.nav-toggle span {
  display: block;
  width: 24px;
  height: 2px;
  background: #fff;
  border-radius: 2px;
  transition: .25s;
}

/* ── Hero ──────────────────────────────────────────────────── */
.hero {
  background: var(--hero-bg);
  color: #fff;
  padding: 6rem 0 5rem;
  text-align: center;
}
.hero-title { color: #fff; }
.hero-sub {
  margin: 1.25rem auto 2rem;
  max-width: 540px;
  color: rgba(255,255,255,.68);
  font-size: 1.0625rem;
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .55rem 1.25rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: .9375rem;
  transition: background .15s, border-color .15s, color .15s, opacity .15s;
  white-space: nowrap;
}
.btn:disabled { opacity: .55; cursor: not-allowed; pointer-events: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.btn-secondary:hover { background: var(--bg-alt); }
.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}
.btn-outline:hover { background: var(--primary); color: #fff; }
.btn-lg { padding: .75rem 1.75rem; font-size: 1rem; }

/* ── Tool Card ─────────────────────────────────────────────── */
.tool-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* ── Tabs ──────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: .25rem;
  border-bottom: 2px solid var(--border);
}
.tab {
  padding: .5rem 1rem;
  font-size: .9375rem;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 2.5px solid transparent;
  margin-bottom: -2px;
  transition: color .15s, border-color .15s;
  background: none;
  border-left: none;
  border-right: none;
  border-top: none;
}
.tab:hover { color: var(--primary); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Drop Zone ─────────────────────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 2.5rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .5rem;
}
.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--primary);
  background: rgba(79,70,229,.03);
}
.drop-icon { color: var(--text-muted); flex-shrink: 0; }
.drop-text { font-weight: 500; color: var(--text); }
.drop-or { color: var(--text-muted); font-size: .875rem; }

/* ── File List ─────────────────────────────────────────────── */
.file-list {
  display: flex;
  flex-direction: column;
  gap: .4rem;
  margin-top: .75rem;
}
.file-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .4rem .75rem;
  background: var(--bg-alt);
  border-radius: var(--radius-sm);
  font-size: .875rem;
}
.file-item-thumb {
  width: 36px;
  height: 36px;
  object-fit: cover;
  border-radius: 4px;
  background: var(--border);
  flex-shrink: 0;
}
.file-item-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}
.file-item-size { color: var(--text-muted); font-size: .8125rem; flex-shrink: 0; }
.file-item-remove {
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 3px;
  flex-shrink: 0;
  transition: color .15s;
}
.file-item-remove:hover { color: var(--error); }

/* ── URL Textarea ──────────────────────────────────────────── */
.url-textarea {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: .875rem 1rem;
  font-family: "SF Mono", "Fira Code", "Cascadia Code", monospace;
  font-size: .8125rem;
  color: var(--text);
  line-height: 1.7;
  background: var(--bg-alt);
  resize: vertical;
  transition: border-color .15s, background .15s;
}
.url-textarea:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--surface);
}

/* ── Form ──────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: .4rem; }
.form-label { font-size: .9375rem; font-weight: 600; color: var(--text); }
.form-input {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .625rem .875rem;
  color: var(--text);
  background: var(--surface);
  transition: border-color .15s;
}
.form-input:focus { outline: none; border-color: var(--primary); }
textarea.form-input { resize: vertical; }

/* ── Operation Grid ────────────────────────────────────────── */
.op-grid {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}
.op-card {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .45rem .9rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: .875rem;
  font-weight: 500;
  transition: border-color .15s, background .15s, color .15s;
  user-select: none;
  position: relative;
}
.op-card:hover { border-color: var(--primary); color: var(--primary); }
.op-card input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}
.op-card:has(input:checked) {
  border-color: var(--primary);
  background: rgba(200,90,56,.08);
  color: var(--primary);
  font-weight: 600;
}

/* ── Slider ────────────────────────────────────────────────── */
.slider {
  width: 100%;
  accent-color: var(--primary);
  cursor: pointer;
  height: 4px;
}

/* ── Spinner ───────────────────────────────────────────────── */
.spinner-wrap {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
}
@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin .7s linear infinite; display: block; }

/* ── Alerts ────────────────────────────────────────────────── */
.alert {
  padding: .75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: .9375rem;
  line-height: 1.5;
  border-width: 1px;
  border-style: solid;
}
.alert-error {
  background: var(--error-bg);
  color: var(--error);
  border-color: var(--error-border);
}
.alert-success {
  background: var(--success-bg);
  color: var(--success);
  border-color: var(--success-border);
}

/* ── Results ───────────────────────────────────────────────── */
.results { border-top: 2px solid var(--border); padding-top: 1.5rem; }
.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: .75rem;
}
.results-header h3 { display: flex; align-items: center; gap: .5rem; }
.badge {
  display: inline-block;
  padding: .1rem .5rem;
  background: var(--primary);
  color: #fff;
  border-radius: 99px;
  font-size: .75rem;
  font-weight: 700;
}
.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1rem;
}
.result-item {
  background: var(--bg-alt);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .15s;
}
.result-item:hover { box-shadow: var(--shadow-md); }
.result-thumb-wrap {
  background: var(--border);
  aspect-ratio: 1;
  overflow: hidden;
}
.result-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.result-info {
  padding: .6rem .75rem .25rem;
  display: flex;
  flex-direction: column;
  gap: .2rem;
  flex: 1;
}
.result-name {
  font-size: .8125rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.result-size { font-size: .75rem; color: var(--text-muted); }
.result-dl { padding: .375rem .75rem .65rem; }
.result-dl a {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .3rem;
  font-size: .8125rem;
  font-weight: 600;
  color: var(--primary);
}
.result-dl a:hover { text-decoration: underline; }
.results-errors {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  margin-top: 1rem;
}
.error-item {
  padding: .5rem .875rem;
  background: var(--error-bg);
  border-radius: var(--radius-sm);
  font-size: .875rem;
  color: var(--error);
  border: 1px solid var(--error-border);
}
.error-item strong { font-weight: 600; }

/* ── Progress Bar ──────────────────────────────────────────── */
.progress-wrap {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.progress-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.progress-text {
  font-size: .875rem;
  color: var(--text-muted);
}
.progress-track {
  background: var(--border);
  border-radius: 999px;
  height: 6px;
  overflow: hidden;
}
.progress-fill {
  background: var(--primary);
  height: 100%;
  border-radius: 999px;
  width: 0%;
  transition: width .25s ease;
}

/* ── Footer ────────────────────────────────────────────────── */
.footer {
  background: var(--hero-bg);
  color: rgba(255,255,255,.45);
  padding: 2rem 0;
  text-align: center;
  font-size: .875rem;
}
.footer-link {
  color: var(--amber);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.footer-link:hover { color: #fff; }

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 768px) {
  .nav-toggle { display: flex; }
  .nav-links {
    position: absolute;
    top: var(--nav-h);
    left: 0;
    right: 0;
    background: var(--hero-bg);
    flex-direction: column;
    gap: 0;
    display: none;
    padding: .5rem 0 1rem;
    border-top: 1px solid rgba(255,255,255,.1);
    box-shadow: 0 8px 16px rgba(0,0,0,.2);
  }
  .nav-links.open { display: flex; }
  .nav-link { padding: .75rem 1.5rem; display: block; }

  .hero { padding: 4rem 0 3.5rem; }
  .section { padding: 3.5rem 0; }
  .tool-card { padding: 1.25rem; gap: 1.25rem; }
  .results-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
  .results-header { flex-direction: column; align-items: flex-start; }
}
