:root {
  --bg: #f7f6fc; --card: #ffffff; --text: #17142b; --muted: #635f7a; --line: #e6e3f2;
  --brand: #6d4aff; --brand-2: #ff4f8b; --brand-dark: #5634e6; --brand-soft: #f0ecff;
  --ok: #12a150; --warn: #c2410c;
  --grad: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);
  --shadow: 0 12px 34px rgba(40, 24, 110, .09);
  --radius: 16px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f0d1a; --card: #181527; --text: #f1effa; --muted: #a29dbd; --line: #2c2843;
    --brand-soft: #251d47; --shadow: 0 12px 34px rgba(0, 0, 0, .4); }
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
body { margin: 0; font: 16px/1.65 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--brand); }
img, svg, canvas { display: block; max-width: 100%; }
.wrap { max-width: 960px; margin: 0 auto; padding: 0 16px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* header */
.top { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.top .wrap { display: flex; align-items: center; justify-content: space-between; height: 62px; gap: 12px; }
.logo { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 21px; color: var(--text); text-decoration: none; letter-spacing: -.3px; }
.logo svg { width: 32px; height: 32px; }
.nav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.nav a { color: var(--muted); text-decoration: none; font-weight: 600; font-size: 14.5px; padding: 7px 11px; border-radius: 9px; white-space: nowrap; }
.nav a:hover, .nav a[aria-current] { color: var(--brand); background: var(--brand-soft); }
@media (max-width: 720px) { .nav { display: none; } .menu-btn { display: grid !important; } }
.menu-btn { display: none; place-items: center; width: 42px; height: 42px; border: 1px solid var(--line); background: transparent; border-radius: 10px; color: var(--text); cursor: pointer; }
.top.open .nav { display: flex; position: absolute; top: 62px; left: 0; right: 0; flex-direction: column; background: var(--card); border-bottom: 1px solid var(--line); padding: 8px 16px 14px; }

/* hero */
.hero { text-align: center; padding: 44px 0 22px; }
.hero h1 { font-size: clamp(28px, 5.2vw, 44px); line-height: 1.12; margin: 0 0 12px; letter-spacing: -.8px; }
.hero h1 em { font-style: normal; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { color: var(--muted); margin: 0 auto; max-width: 640px; font-size: 17px; }
.badges { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 16px; }
.badge { font-size: 13.5px; font-weight: 600; color: var(--muted); background: var(--card); border: 1px solid var(--line); padding: 5px 12px; border-radius: 99px; }

/* tool */
.tool { background: var(--card); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); padding: 22px; margin-top: 8px; }
.drop { border: 2.5px dashed var(--line); border-radius: var(--radius); padding: 40px 18px; text-align: center; cursor: pointer; transition: .15s; background: var(--bg); }
.drop:hover, .drop.over { border-color: var(--brand); background: var(--brand-soft); }
.drop strong { display: block; font-size: 19px; margin: 10px 0 4px; }
.drop span { color: var(--muted); font-size: 14.5px; }
.drop .ico { width: 54px; height: 54px; margin: 0 auto; border-radius: 16px; background: var(--grad); display: grid; place-items: center; color: #fff; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 48px; padding: 0 24px; border: 0; border-radius: 12px;
  background: var(--grad); color: #fff; font: inherit; font-weight: 700; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { filter: brightness(1.07); }
.btn:disabled { opacity: .55; cursor: default; filter: none; }
.btn.ghost { background: transparent; color: var(--text); border: 2px solid var(--line); }
.btn.ghost:hover { border-color: var(--brand); color: var(--brand); }
.btn.ok { background: var(--ok); }
.btn.sm { height: 40px; padding: 0 14px; font-size: 14.5px; }

.editor { display: none; }
.filebar { display: flex; align-items: center; gap: 12px; justify-content: space-between; flex-wrap: wrap; margin-bottom: 12px; }
.filebar b { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; display: block; }
.filebar small { color: var(--muted); }
.wave { position: relative; height: 128px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line); touch-action: none; cursor: crosshair; user-select: none; }
.wave canvas { width: 100%; height: 100%; }
.wave .busy { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 14px; }
.controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 12px; }
.time { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); font-weight: 600; }
.time input { width: 92px; height: 40px; border-radius: 10px; border: 2px solid var(--line); background: var(--bg); color: var(--text); padding: 0 10px; font: inherit; font-weight: 700; font-variant-numeric: tabular-nums; }
.sel-len { margin-left: auto; font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.opts { display: flex; flex-wrap: wrap; gap: 14px 18px; align-items: center; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.opts label { font-size: 14.5px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
select { height: 42px; border-radius: 10px; border: 2px solid var(--line); background: var(--bg); color: var(--text); padding: 0 10px; font: inherit; font-weight: 600; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--brand); }
input[type=range] { accent-color: var(--brand); width: 140px; }
.seg { display: inline-flex; border: 2px solid var(--line); border-radius: 11px; overflow: hidden; }
.seg button { border: 0; background: transparent; color: var(--text); font: inherit; font-weight: 700; font-size: 14px; padding: 8px 14px; cursor: pointer; }
.seg button.on { background: var(--brand-soft); color: var(--brand); }
.go { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 18px; }
.progress { flex: 1; min-width: 200px; display: none; }
.bar { height: 10px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--grad); transition: width .25s; }
.progress small { display: block; color: var(--muted); margin-top: 5px; font-size: 13.5px; }
.note { margin-top: 12px; padding: 10px 14px; border-radius: 10px; font-size: 14.5px; font-weight: 600; display: none; }
.note.err { display: block; background: #fdecec; color: #b42318; }
.note.info { display: block; background: var(--brand-soft); color: var(--brand); }
@media (prefers-color-scheme: dark) { .note.err { background: #3b1518; color: #ffb4ab; } }
.private { display: flex; gap: 8px; align-items: center; justify-content: center; color: var(--muted); font-size: 13.5px; margin-top: 14px; }

/* ads: hidden until an AdSense client id is configured */
.ad { display: none; margin: 26px auto; text-align: center; min-height: 90px; }
.ad.on { display: block; }
.ad::before { content: "Advertisement"; display: block; font-size: 11px; color: var(--muted); letter-spacing: .5px; text-transform: uppercase; margin-bottom: 4px; }

/* content */
.section { margin: 54px 0; }
.section h2 { font-size: 26px; margin: 0 0 14px; letter-spacing: -.4px; }
.section h3 { font-size: 18px; margin: 22px 0 6px; }
.section p, .section li { color: var(--muted); }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; text-decoration: none; color: var(--text); transition: .15s; display: block; }
a.card:hover { border-color: var(--brand); transform: translateY(-2px); box-shadow: var(--shadow); }
.card .ico { width: 44px; height: 44px; border-radius: 13px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; margin-bottom: 10px; }
.card b { display: block; font-size: 17px; margin-bottom: 4px; }
.card p { margin: 0; color: var(--muted); font-size: 14.5px; }
.steps { counter-reset: s; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.steps .card::before { counter-increment: s; content: counter(s); display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--grad); color: #fff; font-weight: 800; margin-bottom: 10px; }
details { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 18px; margin-bottom: 10px; }
summary { font-weight: 700; cursor: pointer; }
details p { margin: 10px 0 0; }
.prose { max-width: 720px; }

footer { border-top: 1px solid var(--line); padding: 30px 0 44px; color: var(--muted); font-size: 14px; }
footer .wrap { display: flex; flex-wrap: wrap; gap: 14px 26px; justify-content: space-between; }
footer nav { display: flex; flex-wrap: wrap; gap: 8px 18px; }
footer a { color: var(--muted); text-decoration: none; }
footer a:hover { color: var(--brand); }

/* effects studio */
.fx { margin-top: 16px; border: 1px solid var(--line); border-radius: 14px; padding: 0; background: var(--bg); }
.fx > summary { padding: 14px 16px; font-weight: 800; list-style: none; display: flex; align-items: center; gap: 8px; }
.fx > summary::-webkit-details-marker { display: none; }
.fx > summary::after { content: "▾"; margin-left: auto; color: var(--muted); transition: transform .2s; }
.fx[open] > summary::after { transform: rotate(180deg); }
.fx > summary small { background: var(--grad); color: #fff; font-size: 12px; padding: 2px 8px; border-radius: 99px; }
.fx > summary small:empty { display: none; }
.presets { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 16px 6px; }
.chip { border: 2px solid var(--line); background: var(--card); color: var(--text); font: inherit; font-size: 13.5px; font-weight: 700; padding: 6px 13px; border-radius: 99px; cursor: pointer; }
.chip:hover { border-color: var(--brand); color: var(--brand); }
.chip.on { border-color: transparent; background: var(--grad); color: #fff; }
.chip.ghost { color: var(--muted); }
.fx-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px 22px; padding: 12px 16px 4px; }
.fx-s { display: flex; flex-direction: column; gap: 4px; font-size: 14px; font-weight: 700; }
.fx-s span { display: flex; justify-content: space-between; gap: 10px; width: 100%; }
.fx-s output { color: var(--brand); font-weight: 700; font-variant-numeric: tabular-nums; }
.fx-s input[type=range] { width: 100%; }
.fx-toggles { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 16px; }
.fx-t { display: inline-flex; align-items: center; gap: 7px; font-size: 14px; font-weight: 700; border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 7px 11px; cursor: pointer; }
.fx-t:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.fx-preview { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 4px 16px 16px; }
.fx-preview small { color: var(--muted); font-size: 13.5px; }

/* joiner */
.joinlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.joinlist li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); min-width: 0; }
.joinlist b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
.joinlist small { color: var(--muted); font-variant-numeric: tabular-nums; }
.jn { width: 26px; height: 26px; flex-shrink: 0; border-radius: 50%; background: var(--grad); color: #fff; font-weight: 800; font-size: 13px; display: grid; place-items: center; }
.jb { display: flex; gap: 4px; }
.jb button { width: 32px; height: 32px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--text); cursor: pointer; font-weight: 700; }
.jb button:disabled { opacity: .35; cursor: default; }

/* badges for AI + install */
.ai { display: inline-block; font-size: 11px; font-weight: 800; letter-spacing: .4px; padding: 2px 7px; border-radius: 99px; background: var(--grad); color: #fff; vertical-align: middle; margin-left: 6px; }
.install-btn { display: none; }
.can-install .install-btn { display: inline-flex; }
.install-native { display: none !important; }
.can-native-install .install-native { display: flex !important; }
.guide-steps { counter-reset: g; list-style: none; padding: 0; display: grid; gap: 10px; }
.guide-steps li { position: relative; padding: 12px 14px 12px 52px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; color: var(--text) !important; }
.guide-steps li::before { counter-increment: g; content: counter(g); position: absolute; left: 12px; top: 11px; width: 28px; height: 28px; border-radius: 50%; background: var(--grad); color: #fff; font-weight: 800; display: grid; place-items: center; font-size: 14px; }
.callout { background: var(--brand-soft); border-radius: 14px; padding: 16px 18px; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; justify-content: space-between; }
.callout p { margin: 0; color: var(--text) !important; font-weight: 600; }

/* visualizer lanes */
.lane { margin-top: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); padding: 8px 10px 6px; }
.lane-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 13px; }
.lane-head b { font-size: 13px; }
.lane-head small { color: var(--muted); text-align: right; font-size: 12.5px; }
.lane canvas { width: 100%; height: 64px; margin-top: 4px; }

/* joiner: per-file play + result player */
.jplay { width: 32px; height: 32px; flex-shrink: 0; border: 1px solid var(--line); border-radius: 50%; background: var(--card); color: var(--brand); cursor: pointer; font-size: 12px; display: grid; place-items: center; }
.joinlist li.playing { border-color: var(--brand); background: var(--brand-soft); }
.result { margin-top: 14px; padding: 14px; border: 1px solid var(--brand); border-radius: 12px; background: var(--brand-soft); display: grid; gap: 8px; }
.result audio { width: 100%; }

/* clean taps on phones; visible focus ring for keyboard users */
* { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; border-radius: 8px; }

/* ---------- phone polish ---------- */
@media (max-width: 640px) {
  body { font-size: 15.5px; }
  .wrap { padding: 0 14px; }
  .top .wrap { height: 56px; }
  .logo { font-size: 19px; }
  .logo img, .logo svg { width: 28px; height: 28px; }
  .install-btn { height: 36px; padding: 0 12px; font-size: 13.5px; border-radius: 10px; }
  .menu-btn { width: 38px; height: 38px; }
  .top.open .nav { top: 56px; }
  .top.open .nav a { padding: 11px 12px; font-size: 16px; }

  .hero { padding: 26px 0 14px; }
  .hero h1 { font-size: 28px; letter-spacing: -.5px; }
  .hero p { font-size: 15.5px; }
  .badges { gap: 6px; margin-top: 12px; }
  .badge { font-size: 12.5px; padding: 4px 10px; }

  .section { margin: 36px 0; }
  .section h2 { font-size: 21px; margin-bottom: 12px; }

  /* tool cards: compact 2-column grid */
  .cards { grid-template-columns: 1fr 1fr; gap: 10px; }
  .card { padding: 13px; border-radius: 14px; }
  .card .ico { width: 36px; height: 36px; border-radius: 11px; margin-bottom: 8px; }
  .card .ico svg { width: 19px; height: 19px; }
  .card b { font-size: 14.5px; line-height: 1.3; margin-bottom: 3px; }
  .card p { font-size: 12.5px; line-height: 1.45; }
  .ai { font-size: 9.5px; padding: 1px 5px; margin-left: 4px; }
  /* "More free tools": swipeable row */
  .cards.rail { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 10px; margin: 0 -14px; padding: 2px 14px 10px; scrollbar-width: none; }
  .cards.rail::-webkit-scrollbar { display: none; }
  .cards.rail .card { flex: 0 0 62%; scroll-snap-align: start; }
  .steps { grid-template-columns: 1fr; gap: 8px; }
  .steps .card { display: grid; grid-template-columns: 32px 1fr; column-gap: 12px; align-items: start; }
  .steps .card::before { grid-row: span 2; margin: 0; }

  /* the tool */
  .tool { padding: 14px; border-radius: 18px; }
  .drop { padding: 30px 14px; }
  .drop strong { font-size: 17px; }
  .filebar { gap: 8px; }
  .filebar .btn { height: 36px; font-size: 13.5px; padding: 0 12px; }
  .wave { height: 104px; }
  .lane { padding: 7px 9px 5px; }
  .lane-head { flex-direction: column; gap: 0; }
  .lane-head small { text-align: left; font-size: 11.5px; }
  .lane canvas { height: 52px; }
  .controls { gap: 8px; }
  .controls .btn { height: 40px; }
  .time { font-size: 13px; }
  .time input { width: 84px; }
  /* iOS zooms into fields under 16px: keep them at 16px */
  input, select, textarea, .time input { font-size: 16px !important; }
  .sel-len { width: 100%; margin-left: 0; font-size: 13px; }
  .opts { gap: 10px 12px; }
  .opts > label { flex: 1 1 140px; justify-content: space-between; }
  .opts select { flex: 1; min-width: 0; }

  /* effects panel */
  .fx > summary { padding: 12px 14px; }
  .presets { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding: 0 14px 8px; }
  .presets::-webkit-scrollbar { display: none; }
  .chip { flex: 0 0 auto; font-size: 13px; padding: 6px 12px; }
  .fx-grid { grid-template-columns: 1fr 1fr; gap: 10px 16px; padding: 10px 14px 2px; }
  .fx-s { font-size: 13px; }
  .fx-toggles { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; padding: 10px 14px; }
  .fx-t { font-size: 13px; padding: 8px 9px; gap: 6px; }
  .fx-t input { width: 16px; height: 16px; flex-shrink: 0; }
  .fx-preview { padding: 2px 14px 14px; }
  .fx-preview .btn { width: 100%; }

  /* Convert / Download always reachable: sticky bar at the bottom of the screen */
  .go { position: sticky; bottom: 0; z-index: 6; margin: 14px -14px -14px; padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
    background: var(--card); border-top: 1px solid var(--line); border-radius: 0 0 18px 18px; box-shadow: 0 -8px 20px rgba(40, 24, 110, .08); }
  .go .btn { flex: 1 1 100%; height: 50px; font-size: 16.5px; }
  .progress { min-width: 0; flex: 1 1 100%; }
  .note { font-size: 14px; }

  /* joiner list */
  .joinlist li { padding: 8px 9px; gap: 8px; }
  .joinlist b { font-size: 14px; }
  .jb button, .jplay { width: 30px; height: 30px; }

  details { padding: 12px 14px; }
  .callout { padding: 14px; }
  .callout .btn { width: 100%; }
  .guide-steps li { padding: 11px 12px 11px 48px; font-size: 15px; }
  footer { padding: 24px 0 calc(32px + env(safe-area-inset-bottom)); font-size: 13px; }
}
@media (max-width: 360px) {
  .cards:not(.rail) { grid-template-columns: 1fr; }
  .fx-grid, .fx-toggles { grid-template-columns: 1fr; }
}

/* breadcrumbs, conversion links, footer groups */
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13.5px; color: var(--muted); padding-top: 16px; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--brand); }
.crumbs .sep { opacity: .6; }
.crumbs [aria-current] { color: var(--text); font-weight: 600; }
.crumbs + .hero { padding-top: 18px; }
.chips-links { display: flex; flex-wrap: wrap; gap: 8px; }
.chips-links .chip { text-decoration: none; }
footer .wrap { flex-direction: column; }
footer nav { padding-top: 2px; }
@media (max-width: 640px) { .crumbs { font-size: 12.5px; padding-top: 12px; } .crumbs + .hero { padding-top: 12px; } }

/* reserve the tool's first-render height so the page doesn't jump while the script loads */
.tool[data-tool] { min-height: 292px; }
@media (max-width: 640px) { .tool[data-tool] { min-height: 300px; } .tool[data-tool="joiner"] { min-height: 328px; } }

/* grouped footer */
.fcols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px; width: 100%; }
.fcols nav { flex-direction: column; gap: 7px; }
.fcols b { color: var(--text); font-size: 13.5px; margin-bottom: 2px; }
@media (max-width: 640px) { .fcols { grid-template-columns: 1fr 1fr; } .fcols nav:first-child { grid-row: span 2; } }
.install-btn { gap: 6px; align-items: center; }
.install-btn svg { flex: none; }
/* the equalizer only takes space once something plays */
.lane.eq-lane { display: none; }
.lane.eq-lane.on { display: block; }
.btn.fx-play { display: none; }
.has-fx .btn.fx-play { display: inline-flex; }
