/* =============================================================
   1. Tokens
   ============================================================= */
:root {
  /* Brand: forest green accent on a white surface, soft gray text.
     Fixed palette — no automatic dark-mode variant, by design, so the site
     always looks the same regardless of the visitor's device theme. */
  --bg: #ffffff;
  --bg-elevated: #f5f5f3;
  --card: #ffffff;
  --card-border: #e2e2de;
  --text: #24281f;
  --text-dim: #5c6459;
  --text-faint: #6b7367;
  --accent: #14532d;
  --accent-strong: #0e3d21;
  --accent-ink: #ffffff;
  --success: #14532d;
  --success-bg: rgba(20, 83, 45, 0.08);
  --warn: #92400e;
  --warn-bg: rgba(146, 64, 14, 0.08);
  --error: #b91c1c;
  --error-bg: rgba(185, 28, 28, 0.06);
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --display: "Manrope", var(--sans);
  --radius: 14px;
  --radius-sm: 9px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --container: 1080px;
}

/* =============================================================
   2. Reset & base
   ============================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; tab-size: 2; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
  overscroll-behavior-y: none;
}
img, svg, video { display: block; max-width: 100%; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
a { color: inherit; text-decoration: none; }
input { font: inherit; color: inherit; }
p { text-wrap: pretty; }
h1, h2, h3, h4 { font-family: var(--display); text-wrap: balance; line-height: 1.1; letter-spacing: -0.01em; font-weight: 800; }
::selection { background: var(--accent); color: var(--accent-ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

/* =============================================================
   3. Utilities
   ============================================================= */
.container { max-width: var(--container); margin-inline: auto; padding-inline: 1.25rem; }
.skip-link {
  position: fixed; top: -100px; left: 1rem; z-index: 9999;
  padding: 0.6rem 1rem; background: var(--accent); color: var(--accent-ink);
  border-radius: 8px; font-weight: 600;
}
.skip-link:focus { top: 1rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* =============================================================
   4. Header / footer
   ============================================================= */
.site-header { padding-block: 1.1rem; border-bottom: 1px solid var(--card-border); }
.header-row { display: flex; align-items: center; justify-content: space-between; }
.logo { display: flex; align-items: center; gap: 0.5rem; font-family: var(--display); font-weight: 800; font-size: 1.05rem; color: var(--text); }
.logo svg { color: var(--accent); }
.header-nav { display: flex; gap: 1.5rem; }
.header-nav a { color: var(--text-dim); font-weight: 500; font-size: 0.92rem; transition: color 0.2s var(--ease-out); }
.header-nav a:hover { color: var(--text); }

.site-footer { border-top: 1px solid var(--card-border); padding-block: 2rem 1.2rem; margin-top: 3rem; color: var(--text-dim); font-size: 0.88rem; }
.footer-row { display: flex; flex-wrap: wrap; gap: 0.75rem 1.5rem; justify-content: space-between; align-items: center; }
.footer-row nav { display: flex; gap: 1.25rem; }
.footer-row a:hover { color: var(--text); }
.footer-credits { margin-top: 0.9rem; font-size: 0.78rem; color: var(--text-faint); }
.footer-credits a { text-decoration: underline; }

/* =============================================================
   5. Hero + tool card
   ============================================================= */
.hero { padding-block: 2.6rem 1.5rem; text-align: center; }
.hero h1 { font-size: clamp(1.9rem, 4.4vw, 2.9rem); max-width: 20ch; margin-inline: auto; }
.hero-sub { color: var(--text-dim); max-width: 56ch; margin: 0.9rem auto 0; font-size: 1.05rem; }

.tool-card {
  margin: 2rem auto 0;
  max-width: 640px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 1.6rem;
  text-align: left;
  box-shadow: 0 20px 60px -30px rgba(0,0,0,0.5);
}

.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 0.5rem;
  text-align: center; padding: 2.4rem 1.5rem;
  border: 1.5px dashed var(--card-border); border-radius: var(--radius-sm);
  cursor: pointer; transition: border-color 0.2s var(--ease-out), background 0.2s var(--ease-out);
}
.dropzone svg { color: var(--accent); margin-bottom: 0.3rem; }
.dropzone strong { font-size: 1.05rem; }
.dropzone span { color: var(--text-dim); font-size: 0.88rem; }
.dropzone:hover, .dropzone.is-dragover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }

.tc-limits { text-align: center; color: var(--text-faint); font-size: 0.82rem; margin-top: 0.9rem; }

.file-summary {
  display: flex; align-items: center; gap: 0.7rem;
  background: var(--bg-elevated); border: 1px solid var(--card-border); border-radius: var(--radius-sm);
  padding: 0.7rem 0.9rem; font-size: 0.9rem; margin-bottom: 1.2rem;
}
.file-summary .fs-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-summary .fs-meta { color: var(--text-dim); font-size: 0.82rem; }

.config-grid { display: flex; flex-direction: column; gap: 1.1rem; margin-bottom: 1.3rem; }
.config-label { display: block; font-weight: 700; font-size: 0.86rem; margin-bottom: 0.55rem; }

.size-chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chip {
  padding: 0.5rem 0.95rem; border-radius: 999px; border: 1px solid var(--card-border);
  background: var(--bg-elevated); font-weight: 600; font-size: 0.88rem;
  transition: border-color 0.15s var(--ease-out), color 0.15s var(--ease-out), background 0.15s var(--ease-out);
}
.chip:hover { border-color: var(--accent); }
.chip.is-active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.size-custom { margin-top: 0.65rem; }
.size-custom label { display: block; font-size: 0.8rem; color: var(--text-dim); margin-bottom: 0.35rem; }
.size-custom-row { display: flex; align-items: center; gap: 0.5rem; max-width: 180px; }
.size-custom-row input {
  width: 100%; padding: 0.55rem 0.7rem; border-radius: var(--radius-sm); border: 1px solid var(--card-border);
  background: var(--bg-elevated); color: var(--text);
}
.size-custom-row span { color: var(--text-dim); font-size: 0.85rem; }

.seg { display: inline-flex; background: var(--bg-elevated); border: 1px solid var(--card-border); border-radius: var(--radius-sm); padding: 3px; gap: 3px; }
.seg button {
  padding: 0.45rem 0.9rem; border-radius: calc(var(--radius-sm) - 3px); font-weight: 600; font-size: 0.86rem;
  color: var(--text-dim); transition: background 0.15s var(--ease-out), color 0.15s var(--ease-out);
}
.seg button.is-active { background: var(--accent); color: var(--accent-ink); }

.switch-row { display: flex; align-items: center; gap: 0.6rem; font-size: 0.92rem; }
.switch-row input { width: 18px; height: 18px; accent-color: var(--accent); }
.switch-row em { font-style: normal; color: var(--success); font-weight: 600; }

.trim-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.trim-row label { font-size: 0.82rem; color: var(--text-dim); display: flex; flex-direction: column; gap: 0.3rem; }
.trim-row input { width: 100px; padding: 0.5rem 0.6rem; border-radius: var(--radius-sm); border: 1px solid var(--card-border); background: var(--bg-elevated); color: var(--text); }
.hint { font-size: 0.8rem; color: var(--text-faint); margin-top: 0.5rem; }

.btn { display: inline-flex; align-items: center; justify-content: center; border-radius: var(--radius-sm); font-weight: 700; transition: transform 0.15s var(--ease-out), background 0.15s var(--ease-out), opacity 0.15s; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-strong); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-big { width: 100%; padding: 0.95rem 1.2rem; font-size: 1.02rem; }
.btn-link { display: block; text-align: center; margin-top: 0.85rem; color: var(--text-dim); font-size: 0.88rem; text-decoration: underline; text-underline-offset: 3px; }
.btn-link:hover { color: var(--text); }

.tc-note { text-align: center; font-size: 0.8rem; color: var(--text-faint); margin-top: 0.7rem; }

/* Working state */
.working-head { display: flex; align-items: center; gap: 0.7rem; margin-bottom: 1rem; }
.spinner { width: 20px; height: 20px; border-radius: 50%; border: 2.5px solid var(--card-border); border-top-color: var(--accent); animation: spin 0.8s linear infinite; flex-shrink: 0; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress-bar { height: 10px; border-radius: 999px; background: var(--bg-elevated); border: 1px solid var(--card-border); overflow: hidden; }
.progress-fill { height: 100%; width: 0%; background: var(--accent); border-radius: 999px; transition: width 0.25s var(--ease-out); }
.progress-pct { text-align: right; font-size: 0.82rem; color: var(--text-dim); margin-top: 0.4rem; font-variant-numeric: tabular-nums; }
.log-box {
  margin-top: 1rem; max-height: 160px; overflow-y: auto; font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 0.78rem; line-height: 1.55; color: var(--text-dim); background: var(--bg-elevated);
  border: 1px solid var(--card-border); border-radius: var(--radius-sm); padding: 0.7rem 0.85rem;
}
.log-box p { margin: 0; }
.log-box p.log-current { color: var(--text); font-weight: 600; }

/* Done state */
.result-banner { padding: 0.8rem 1rem; border-radius: var(--radius-sm); font-weight: 700; margin-bottom: 1.1rem; font-size: 0.95rem; }
.result-banner.ok { background: var(--success-bg); color: var(--success); }
.result-banner.warn { background: var(--warn-bg); color: var(--warn); }
.result-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem; margin-bottom: 1.2rem; }
.result-item { background: var(--bg-elevated); border: 1px solid var(--card-border); border-radius: var(--radius-sm); padding: 0.7rem 0.85rem; }
.result-item .ri-label { display: block; font-size: 0.74rem; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 0.2rem; }
.result-item .ri-value { font-weight: 700; font-size: 0.98rem; }
.result-item.span2 { grid-column: 1 / -1; }

/* Error state */
.error-box { background: var(--error-bg); color: var(--error); border-radius: var(--radius-sm); padding: 1rem 1.1rem; margin-bottom: 1rem; }
.error-box strong { display: block; margin-bottom: 0.3rem; }
.error-box p { color: var(--text); font-size: 0.92rem; }

.privacy-badge { text-align: center; color: var(--text-dim); font-size: 0.85rem; margin: 1.1rem auto 0; max-width: 500px; }

/* =============================================================
   6. Ad slots
   ============================================================= */
.ad-slot {
  margin-block: 2rem; min-height: 90px; border: 1px dashed var(--card-border); border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center; color: var(--text-faint); font-size: 0.8rem;
  letter-spacing: 0.04em; text-transform: uppercase;
}
.ad-incontent { min-height: 250px; }

.ad-popup {
  position: relative; margin: auto; border: 1px solid var(--card-border); border-radius: var(--radius);
  background: var(--card); color: var(--text); padding: 2rem 1.5rem; width: min(420px, calc(100vw - 2rem));
  min-height: 200px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.5rem;
}
.ad-popup::backdrop { background: rgba(0,0,0,0.55); }
.ad-popup-label { color: var(--text-faint); font-size: 0.78rem; letter-spacing: 0.05em; text-transform: uppercase; }
.ad-popup-close { position: absolute; top: 0.6rem; right: 0.7rem; width: 30px; height: 30px; border-radius: 50%; background: var(--bg-elevated); font-size: 1.1rem; display: flex; align-items: center; justify-content: center; }

.ad-corner { position: fixed; bottom: 1rem; right: 1rem; width: 240px; min-height: 100px; background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius-sm); padding: 1rem; z-index: 500; box-shadow: 0 10px 30px -12px rgba(0,0,0,0.4); }
.ad-corner-label { color: var(--text-faint); font-size: 0.72rem; letter-spacing: 0.05em; text-transform: uppercase; }
.ad-corner-close { position: absolute; top: 0.4rem; right: 0.55rem; font-size: 1rem; color: var(--text-dim); }

/* =============================================================
   7. Content sections
   ============================================================= */
.content { padding-block: 2.4rem; }
.content h2 { font-size: clamp(1.4rem, 2.6vw, 1.9rem); margin-bottom: 1.1rem; }
.content p { color: var(--text-dim); max-width: 74ch; margin-bottom: 0.9rem; }
.content .lead { color: var(--text); font-size: 1.02rem; }

.steps { list-style: none; display: grid; gap: 1rem; counter-reset: step; grid-template-columns: repeat(3, 1fr); }
.steps li { counter-increment: step; background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius-sm); padding: 1.2rem; }
.steps li::before { content: counter(step); display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-weight: 800; font-size: 0.85rem; margin-bottom: 0.7rem; }
.steps li h3 { font-size: 1rem; margin-bottom: 0.35rem; }
.steps li p { color: var(--text-dim); font-size: 0.9rem; margin: 0; }

.usecases { display: grid; gap: 1rem; grid-template-columns: repeat(3, 1fr); margin-top: 1.2rem; }
.usecase { background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius-sm); padding: 1.1rem; }
.usecase svg { color: var(--accent); margin-bottom: 0.6rem; }
.usecase h3 { font-size: 0.98rem; margin-bottom: 0.3rem; }
.usecase p { color: var(--text-dim); font-size: 0.87rem; margin: 0; }

.faq-list { display: flex; flex-direction: column; gap: 0.6rem; }
.faq-item { background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius-sm); padding: 0.2rem 1.1rem; }
.faq-item summary { padding: 0.95rem 0; font-weight: 700; cursor: pointer; list-style: none; display: flex; justify-content: space-between; gap: 1rem; align-items: center; }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: "+"; font-size: 1.3rem; color: var(--accent); flex-shrink: 0; transition: transform 0.2s var(--ease-out); }
.faq-item[open] summary::after { transform: rotate(45deg); }
.faq-item p { color: var(--text-dim); padding-bottom: 1rem; margin: 0; font-size: 0.92rem; }

/* =============================================================
   8. Responsive
   ============================================================= */
@media (max-width: 720px) {
  .steps, .usecases { grid-template-columns: 1fr; }
  .result-grid { grid-template-columns: 1fr 1fr; }
  .header-nav { gap: 1rem; }
  .tool-card { padding: 1.2rem; }
  .ad-corner { width: calc(100% - 2rem); right: 1rem; left: 1rem; }
}
@media (min-width: 540px) {
  .config-grid { display: grid; grid-template-columns: 1fr 1fr; }
  #trim-block, #audio-block { grid-column: 1 / -1; }
}

/* =============================================================
   9. Reduced-motion — only intrusive effects
   ============================================================= */
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 1.4s; }
}

/* No-JS notice (rendered via <noscript>, browser handles the conditional) */
.no-js-note { text-align: center; padding: 1rem 1.2rem; margin-top: 1rem; color: var(--warn); background: var(--warn-bg); border-radius: var(--radius-sm); font-size: 0.9rem; font-weight: 600; }
