:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --ink: #17151f;
  --muted: #6c6878;
  --line: #e4e0d8;
  --accent: #6d4aff;
  --accent-ink: #ffffff;
  --pop: #d9ff5c;
  --danger: #d1344b;
  --shadow: 0 1px 2px rgba(23, 21, 31, .06), 0 6px 24px rgba(23, 21, 31, .06);
  --r: 18px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121118; --surface: #1c1a24; --ink: #f1eff7; --muted: #9d98ad; --line: #2d2a38;
    --accent: #8b6dff; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 24px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121118; --surface: #1c1a24; --ink: #f1eff7; --muted: #9d98ad; --line: #2d2a38;
  --accent: #8b6dff; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 24px rgba(0,0,0,.25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 15px/1.5 Inter, system-ui, sans-serif;
  min-height: 100vh; display: flex; flex-direction: column;
}
main { flex: 1; width: 100%; max-width: 1100px; margin: 0 auto; padding: 0 16px 48px; }
a { color: var(--accent); }
h1, h2, h3, .brand { font-family: "Bricolage Grotesque", Inter, sans-serif; }

/* header */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; max-width: 1100px; margin: 0 auto; width: 100%;
  background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(10px);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; color: var(--ink); text-decoration: none; }
.logo { width: 32px; height: 32px; border-radius: 10px; background: var(--accent); display: flex; align-items: center; justify-content: center; gap: 2px; }
.logo i { width: 3px; border-radius: 2px; background: var(--pop); }
.logo i:nth-child(1) { height: 8px } .logo i:nth-child(2) { height: 16px } .logo i:nth-child(3) { height: 11px } .logo i:nth-child(4) { height: 5px }
.tabs { display: flex; gap: 6px; }
.tabs a { padding: 8px 14px; border-radius: 999px; text-decoration: none; color: var(--muted); font-weight: 600; }
.tabs a.on { color: var(--ink); background: var(--surface); box-shadow: var(--shadow); }
.tabs a.cta { color: var(--accent-ink); background: var(--accent); }
.tabs a.cta.on { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }

.hero { padding: 40px 0 24px; }
.hero h1 { font-size: clamp(34px, 7vw, 60px); line-height: 1; margin: 0 0 12px; letter-spacing: -0.02em; }
.hero.small h1 { font-size: clamp(30px, 5vw, 44px); }
.hero p { color: var(--muted); max-width: 520px; margin: 0; font-size: 17px; }

/* buttons + inputs */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: 10px 18px; border-radius: 999px; font: 600 15px Inter, sans-serif;
  cursor: pointer; text-decoration: none; transition: transform .08s, filter .15s;
}
.btn:hover { filter: brightness(.97); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 11px; font-size: 12.5px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .55; cursor: progress; }

input[type=search], input[type=url], input[type=number], .meta input {
  width: 100%; padding: 12px 16px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font: 15px Inter, sans-serif; outline: none;
}
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }

.toolbar { display: flex; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }
.toolbar input { flex: 1 1 240px; }
.seg { display: flex; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 3px; }
.seg button { border: 0; background: none; color: var(--muted); padding: 8px 14px; border-radius: 9px; font: 600 14px Inter; cursor: pointer; }
.seg button.on { background: var(--ink); color: var(--bg); }

/* grid + cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.card {
  background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow);
  padding: 16px; display: flex; flex-direction: column; gap: 12px; min-width: 0;
}
.play {
  width: 100%; aspect-ratio: 16 / 9; border: 0; border-radius: 14px; cursor: pointer;
  background: var(--accent); display: flex; align-items: center; justify-content: center;
  background-size: cover; background-position: center; position: relative; overflow: hidden;
}
/* sticker tile: square, the sticker itself, a small sound badge */
.play { aspect-ratio: 1 / 1; border-radius: 22px; }
.play.has-img { background: var(--bg); }
.sticker-img, .sticker-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.sticker-video { z-index: 1; background: #000; }
.sound-badge {
  position: absolute; right: 10px; bottom: 10px; z-index: 2; width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center; font-size: 15px; background: rgba(0, 0, 0, .55); backdrop-filter: blur(4px);
  transition: transform .15s;
}
.play:hover .sound-badge { transform: scale(1.1); }
.card.playing .sound-badge { background: var(--accent); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.15); } }
.bars { position: relative; display: flex; gap: 5px; align-items: center; height: 46px; }
.bars i { width: 7px; height: 30%; background: var(--pop); border-radius: 4px; transition: height .2s; }
.bars i:nth-child(2) { height: 70% } .bars i:nth-child(3) { height: 100% } .bars i:nth-child(4) { height: 55% } .bars i:nth-child(5) { height: 25% }
.card.playing .bars i { animation: bounce .7s ease-in-out infinite alternate; }
.card.playing .bars i:nth-child(2) { animation-delay: -.2s } .card.playing .bars i:nth-child(3) { animation-delay: -.45s }
.card.playing .bars i:nth-child(4) { animation-delay: -.1s } .card.playing .bars i:nth-child(5) { animation-delay: -.35s }
@keyframes bounce { from { height: 15% } to { height: 100% } }
.info { min-width: 0; }
.name { margin: 0; font-size: 18px; line-height: 1.2; overflow-wrap: anywhere; }
.src { display: block; color: var(--muted); font-size: 13px; text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.src:hover { text-decoration: underline; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.tags span { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); cursor: pointer; }
.foot { display: flex; flex-direction: column; align-items: stretch; gap: 8px; margin-top: auto; }
.dl { flex-wrap: wrap; }
.wa-get { width: 100%; background: #1fa855; color: #fff; border-color: transparent; font-size: 14px; }
.wa-get:hover { filter: brightness(1.05); }
.wa-get.sending { opacity: .7; pointer-events: none; }
.toast {
  position: fixed; left: 50%; bottom: 20px; z-index: 50; max-width: min(92vw, 420px);
  transform: translate(-50%, 140%); transition: transform .25s ease;
  background: var(--ink); color: var(--bg); padding: 12px 16px; border-radius: 14px; box-shadow: var(--shadow); font-size: 14px;
}
.toast.on { transform: translate(-50%, 0); }
.dl .btn:first-child { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.stat { color: var(--muted); font-size: 12.5px; }
.dl { display: flex; gap: 6px; }
.empty { text-align: center; padding: 60px 0; color: var(--muted); }
.skeleton { height: 250px; border-radius: var(--r); background: linear-gradient(90deg, var(--surface), var(--line), var(--surface)); background-size: 200% 100%; animation: shimmer 1.2s infinite linear; }
@keyframes shimmer { to { background-position: -200% 0 } }

/* create */
.load { display: flex; gap: 10px; max-width: 640px; }
.msg { min-height: 1.5em; color: var(--muted); margin: 10px 0; }
.msg.err { color: var(--danger); }
.editor { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 20px; margin-top: 12px; }
@media (max-width: 820px) { .editor { grid-template-columns: 1fr; } }
.player-wrap { background: #000; border-radius: var(--r); overflow: hidden; aspect-ratio: 16 / 9; align-self: start; }
.player-wrap.vertical { aspect-ratio: 9 / 16; height: min(70vh, 620px); width: auto; max-width: 100%; justify-self: center; }
.player-wrap iframe, .player-wrap > div { width: 100%; height: 100%; display: block; }
.panel { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.vid-title { margin: 0; font-weight: 600; overflow-wrap: anywhere; }

.timeline { position: relative; height: 36px; }
.track { position: absolute; left: 0; right: 0; top: 13px; height: 10px; border-radius: 5px; background: var(--line); }
.sel { position: absolute; top: -4px; bottom: -4px; background: var(--accent); border-radius: 6px; }
.head { position: absolute; top: -7px; bottom: -7px; width: 2px; background: var(--ink); opacity: .6; left: 0; }
.timeline input[type=range] {
  position: absolute; inset: 0; width: 100%; margin: 0; background: none; pointer-events: none;
  -webkit-appearance: none; appearance: none; height: 36px;
}
.timeline input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; pointer-events: auto; width: 20px; height: 30px; border-radius: 7px;
  background: var(--pop); border: 2px solid var(--ink); cursor: ew-resize;
}
.timeline input[type=range]::-moz-range-thumb {
  pointer-events: auto; width: 16px; height: 26px; border-radius: 7px; background: var(--pop); border: 2px solid var(--ink); cursor: ew-resize;
}
.timeline input[type=range]::-webkit-slider-runnable-track { background: none; }
.timeline input[type=range]::-moz-range-track { background: none; }

.times { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: end; }
.times label, .meta label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: var(--muted); }
.time-row { display: flex; gap: 4px; }
.time-row input { padding: 8px 10px; min-width: 0; }
.chip { border: 1px solid var(--line); background: var(--bg); color: var(--ink); border-radius: 10px; font: 600 12px Inter; padding: 0 8px; cursor: pointer; white-space: nowrap; }
.dur { text-align: center; font: 800 26px "Bricolage Grotesque", sans-serif; padding-bottom: 2px; }
.dur small { display: block; font: 500 11px Inter; color: var(--muted); }
.dur.bad { color: var(--danger); }
.meta { display: flex; flex-direction: column; gap: 12px; border-top: 1px solid var(--line); padding-top: 14px; }
.meta small { font-weight: 400; }

.result { margin-top: 24px; max-width: 420px; }
.result h2 { margin: 0 0 14px; }
.hint { color: var(--muted); }

.spinner { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg) } }

/* maker: source tabs, upload, waveform, pending jobs */
.source-tabs { display: inline-flex; margin-bottom: 14px; }
.drop {
  display: flex; flex-direction: column; align-items: center; gap: 4px; max-width: 640px; text-align: center;
  position: relative; padding: 28px 16px; border: 2px dashed var(--line); border-radius: var(--r); background: var(--surface); cursor: pointer;
}
.drop[hidden] { display: none; }
.drop.over, .drop:hover { border-color: var(--accent); }
.drop span { color: var(--muted); font-size: 13px; }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop:focus-within { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.wave-wrap { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); padding: 16px; align-self: start; }
.wave-wrap canvas { width: 100%; height: 160px; display: block; cursor: pointer; }
.wave-hint { margin: 8px 0 0; color: var(--muted); font-size: 13px; }
.player-wrap[hidden], .wave-wrap[hidden] { display: none; }
.pending { margin-top: 28px; max-width: 640px; }
.pending h2 { margin: 0 0 6px; }
.pending-item { display: flex; gap: 12px; align-items: flex-start; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); padding: 14px 16px; margin-top: 10px; }
.pending-item .spinner { flex: none; margin-top: 3px; color: var(--accent); }
.pending-item p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.pending-item.error p { color: var(--danger); }
.dot.err { flex: none; width: 12px; height: 12px; border-radius: 50%; background: var(--danger); margin-top: 5px; }
.pending-done { margin-top: 10px; max-width: 360px; }

/* square crop */
.media-col { display: flex; flex-direction: column; gap: 14px; min-width: 0; align-self: start; }
.croppable { position: relative; }
.media-wrap { background: #000; border-radius: var(--r); overflow: hidden; max-height: 70vh; align-self: center; max-width: 100%; }
.media-wrap video, .media-wrap img { display: block; width: 100%; height: 100%; object-fit: contain; }
.crop-layer { position: absolute; inset: 0; z-index: 2; pointer-events: none; overflow: hidden; border-radius: inherit; }
.crop-box {
  position: absolute; pointer-events: auto; cursor: move; touch-action: none;
  outline: 2px solid var(--pop); box-shadow: 0 0 0 9999px rgba(0, 0, 0, .45);
  background-image: linear-gradient(rgba(255,255,255,.25) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.25) 1px, transparent 1px);
  background-size: 33.333% 33.333%; background-position: -1px -1px;
}
.crop-handle {
  position: absolute; right: -9px; bottom: -9px; width: 20px; height: 20px; border-radius: 6px;
  background: var(--pop); border: 2px solid var(--ink); cursor: nwse-resize; touch-action: none;
}
.img-section { display: flex; gap: 14px; align-items: flex-start; border-top: 1px solid var(--line); padding-top: 14px; }
.img-preview { position: relative; flex: none; width: 96px; height: 96px; border-radius: 14px; overflow: hidden; background: var(--bg); border: 1px solid var(--line); display: grid; place-items: center; }
.img-preview canvas { width: 100%; height: 100%; display: block; }
.img-preview span { position: absolute; font-size: 12px; color: var(--muted); }
.img-tools { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.img-tools small { color: var(--muted); font-weight: 400; }
.img-tools .hint { margin: 0; font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips .chip { padding: 6px 10px; position: relative; }
.chips input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; }

/* content sections */
.strip { margin-top: 48px; }
.strip-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.strip-head h2, .prose h2 { font-size: 26px; margin: 0; letter-spacing: -0.01em; }
.strip-head a { font-weight: 600; text-decoration: none; white-space: nowrap; }
.prose { max-width: 720px; margin-top: 56px; }
.prose h2 { margin: 36px 0 14px; }
.steps { padding-left: 22px; display: flex; flex-direction: column; gap: 10px; }
.steps li::marker { font-weight: 800; color: var(--accent); }
.prose code { font-size: 13px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 1px 5px; overflow-wrap: anywhere; }
details { background: var(--surface); border-radius: 14px; padding: 14px 18px; margin-bottom: 8px; box-shadow: var(--shadow); }
summary { font-weight: 600; cursor: pointer; }
details p { color: var(--muted); margin: 8px 0 0; }
.name a { color: inherit; text-decoration: none; }
.name a:hover { text-decoration: underline; }
.tags a { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); text-decoration: none; }
.single { display: grid; grid-template-columns: minmax(0, 360px) minmax(0, 1fr); gap: 32px; align-items: start; }
.single .prose { margin-top: 0; }
.single .prose h2 { margin-top: 0; }
@media (max-width: 720px) { .single { grid-template-columns: 1fr; } }
.crumbs { font-size: 14px; margin-bottom: 8px !important; }
.crumbs a { text-decoration: none; }
.hero .sub { color: var(--muted); font-weight: 700; font-size: .55em; display: block; margin-top: 6px; }
footer nav { margin-bottom: 6px; }
footer nav a { color: var(--muted); }
footer p { margin: 0; }

footer { text-align: center; color: var(--muted); font-size: 12.5px; padding: 24px 16px; }
@media (max-width: 480px) {
  .times { grid-template-columns: 1fr 1fr; }
  .dur { grid-column: 1 / -1; order: -1; }
  .load { flex-direction: column; }
}
