/* FileMorph — base styles (Light theme tokens live here; Dark & Retro in themes.css) */
:root, [data-theme="light"] {
  --bg: #fbf8ff;
  --bg-2: #f3ecff;
  --surface: rgba(255, 255, 255, 0.78);
  --surface-solid: #ffffff;
  --surface-2: rgba(124, 58, 237, 0.06);
  --text: #1d1530;
  --muted: #6b6385;
  --border: rgba(124, 58, 237, 0.16);
  --accent: #7c3aed;
  --accent-ink: #ffffff;
  --accent-2: #ff5fa2;
  --accent-3: #22d3ee;
  --ok: #059669;
  --warn: #b45309;
  --err: #dc2626;
  --ring: 0 0 0 3px rgba(124, 58, 237, 0.45);
  --shadow: 0 18px 40px -20px rgba(76, 29, 149, 0.45), 0 2px 6px rgba(76, 29, 149, 0.06);
  --shadow-lg: 0 30px 60px -24px rgba(76, 29, 149, 0.55);
  --radius: 22px;
  --radius-sm: 14px;
  --blob-1: #ff8fc4;
  --blob-2: #67e8f9;
  --blob-3: #a78bfa;
  --mesh-a: rgba(255, 143, 196, 0.45);
  --mesh-b: rgba(103, 232, 249, 0.40);
  --mesh-c: rgba(167, 139, 250, 0.45);
  --mesh-d: rgba(250, 204, 21, 0.25);
  --font: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Consolas, "Liberation Mono", monospace;
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh;
  font-family: var(--font); font-size: 1rem; line-height: 1.55;
  color: var(--text); background: var(--bg);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
img, canvas, svg { max-width: 100%; }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
h1, h2, h3 { line-height: 1.15; margin: 0 0 .5em; letter-spacing: -0.02em; }
p { margin: 0 0 .8em; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus { outline: none; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 10px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; left: 12px; top: -60px; z-index: 1000; background: var(--accent); color: var(--accent-ink); padding: .6em 1em; border-radius: 12px; transition: top .2s; }
.skip-link:focus { top: 12px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.big-emoji { font-size: 2.6rem; margin: 0; }
kbd { font-family: var(--mono); font-size: .8em; padding: .1em .45em; border-radius: 6px; border: 1px solid var(--border); background: var(--surface-2); box-shadow: 0 2px 0 var(--border); }

/* ------------------------------------------------------------------ */
/* Animated background: gradient mesh + morphing blobs                */
/* ------------------------------------------------------------------ */
.bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; background: var(--bg); }
.mesh {
  position: absolute; inset: -20%;
  background:
    radial-gradient(40% 35% at 15% 20%, var(--mesh-a), transparent 70%),
    radial-gradient(35% 40% at 85% 15%, var(--mesh-b), transparent 70%),
    radial-gradient(45% 40% at 70% 85%, var(--mesh-c), transparent 70%),
    radial-gradient(30% 30% at 25% 80%, var(--mesh-d), transparent 70%);
  filter: saturate(1.1);
  animation: mesh 26s ease-in-out infinite alternate;
}
@keyframes mesh {
  0% { transform: translate3d(0, 0, 0) rotate(0deg) scale(1); }
  50% { transform: translate3d(4%, -3%, 0) rotate(8deg) scale(1.08); }
  100% { transform: translate3d(-3%, 4%, 0) rotate(-6deg) scale(1.02); }
}
.blob { position: absolute; width: 52vmax; height: 52vmax; opacity: .5; filter: blur(48px); will-change: transform; }
.blob path { fill: var(--blob-1); }
.blob.b1 { left: -14vmax; top: -16vmax; animation: drift1 34s ease-in-out infinite alternate; }
.blob.b2 { right: -18vmax; top: 8vh; animation: drift2 40s ease-in-out infinite alternate; }
.blob.b2 path { fill: var(--blob-2); }
.blob.b3 { left: 20vw; bottom: -26vmax; animation: drift1 46s ease-in-out infinite alternate-reverse; }
.blob.b3 path { fill: var(--blob-3); }
@keyframes drift1 { to { transform: translate3d(10vw, 8vh, 0) rotate(40deg) scale(1.1); } }
@keyframes drift2 { to { transform: translate3d(-12vw, 12vh, 0) rotate(-30deg) scale(.92); } }
.grain { position: absolute; inset: 0; opacity: .035; background-image: radial-gradient(#000 0.6px, transparent 0.6px); background-size: 3px 3px; }

/* ------------------------------------------------------------------ */
/* Top bar                                                            */
/* ------------------------------------------------------------------ */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: .8rem 1.2rem; flex-wrap: wrap;
  padding: .7rem clamp(.8rem, 3vw, 2rem);
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  -webkit-backdrop-filter: blur(14px) saturate(1.4); backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid var(--border);
}
@supports not (background: color-mix(in srgb, red 50%, blue)) { .topbar { background: var(--surface); } }
.brand { display: flex; align-items: center; gap: .55rem; background: none; border: 0; padding: .2rem; cursor: pointer; border-radius: 14px; }
.brand-mark { width: 42px; height: 42px; transition: transform .5s var(--spring); }
.brand:hover .brand-mark { transform: rotate(-12deg) scale(1.08); }
.brand:active .brand-mark { transform: scale(.9); }
.brand-name { font-size: 1.35rem; font-weight: 700; letter-spacing: -0.03em; }
.brand-name b { background: linear-gradient(90deg, var(--accent-2), var(--accent), var(--accent-3)); -webkit-background-clip: text; background-clip: text; color: transparent; font-weight: 900; }
.tabs { display: flex; gap: .3rem; flex-wrap: wrap; margin-left: auto; }
.tab {
  position: relative; border: 0; background: transparent; padding: .5rem .9rem; border-radius: 999px; cursor: pointer;
  font-weight: 650; color: var(--muted); transition: background .2s, color .2s, transform .35s var(--spring);
}
.tab:hover { color: var(--text); background: var(--surface-2); transform: translateY(-1px); }
.tab[aria-current="page"] { color: var(--accent-ink); background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 8px 18px -8px var(--accent); }
.badge { display: inline-grid; place-items: center; min-width: 1.4em; height: 1.4em; padding: 0 .35em; margin-left: .2em; border-radius: 999px; font-size: .72rem; background: var(--accent-2); color: #fff; }
.theme-switch { display: flex; gap: 2px; padding: 3px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); }
.theme-switch button { border: 0; background: transparent; width: 2.2rem; height: 2.2rem; border-radius: 999px; cursor: pointer; font-size: 1rem; transition: transform .35s var(--spring), background .2s; }
.theme-switch button:hover { transform: scale(1.12) rotate(-8deg); }
.theme-switch button[aria-pressed="true"] { background: var(--surface-solid); box-shadow: 0 3px 10px -4px rgba(0, 0, 0, .3); }

/* ------------------------------------------------------------------ */
/* Layout                                                             */
/* ------------------------------------------------------------------ */
main { width: min(1180px, 100%); margin: 0 auto; padding: clamp(1rem, 3vw, 2.2rem) clamp(.8rem, 3vw, 2rem) 3rem; }
main:focus { box-shadow: none; }
.view { animation: viewIn .45s var(--ease); }
@keyframes viewIn { from { opacity: 0; transform: translateY(10px); } }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: clamp(1rem, 2.5vw, 1.6rem);
  -webkit-backdrop-filter: blur(16px) saturate(1.3); backdrop-filter: blur(16px) saturate(1.3);
  margin-bottom: 1.2rem;
}
.section-head { text-align: center; margin: .5rem auto 1.6rem; max-width: 760px; }
.section-head h1 { font-size: clamp(2rem, 5vw, 3.2rem); }
.lede { font-size: clamp(1.02rem, 1.6vw, 1.2rem); color: var(--muted); max-width: 720px; margin: 0 auto 1rem; }
.lede.sm { font-size: 1.02rem; }

/* Hero */
.hero { text-align: center; padding-top: clamp(.5rem, 3vw, 2rem); }
.eyebrow { display: inline-flex; align-items: center; gap: .5rem; font-size: .88rem; font-weight: 650; color: var(--accent); background: var(--surface); border: 1px solid var(--border); padding: .35rem .85rem; border-radius: 999px; }
.eyebrow .dot { width: .55rem; height: .55rem; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 0 rgba(16, 185, 129, .6); animation: pulse 2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 9px rgba(16, 185, 129, 0); } 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); } }
.hero h1 { font-size: clamp(2.3rem, 6.5vw, 4.8rem); font-weight: 900; margin: .7rem 0 .6rem; letter-spacing: -0.045em; }
.morph-word {
  display: inline-block; background: linear-gradient(90deg, var(--accent-2), var(--accent), var(--accent-3), var(--accent-2));
  background-size: 300% 100%; -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: shimmer 6s linear infinite; transition: transform .26s var(--ease), opacity .26s, filter .26s;
}
.morph-word.out { transform: translateY(.15em) scale(.85, 1.15); opacity: 0; filter: blur(6px); }
@keyframes shimmer { to { background-position: 300% 0; } }

/* Search */
.search { position: relative; max-width: 640px; margin: 1.4rem auto 1.2rem; }
.search-label { display: block; text-align: center; font-weight: 750; margin-bottom: .45rem; }
.search-box {
  display: flex; align-items: center; gap: .6rem; padding: .35rem .5rem .35rem 1rem;
  background: var(--surface-solid); border: 2px solid var(--border); border-radius: 999px;
  box-shadow: var(--shadow); transition: border-color .2s, transform .35s var(--spring);
}
.search-box:focus-within { border-color: var(--accent); transform: scale(1.015); }
.search-box input { flex: 1; min-width: 0; border: 0; background: transparent; padding: .6rem 0; font-size: 1.05rem; }
.search-box input::-webkit-search-cancel-button { cursor: pointer; }
.search-box input:focus-visible { box-shadow: none; }
.search-kbd { margin-right: .4rem; }
.suggest {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 40; list-style: none; margin: 0; padding: .4rem;
  background: var(--surface-solid); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow-lg);
  max-height: 60vh; overflow: auto; animation: pop .25s var(--spring);
}
.suggest-item { display: flex; gap: .7rem; align-items: center; padding: .55rem .7rem; border-radius: 12px; cursor: pointer; }
.suggest-item[aria-selected="true"], .suggest-item:hover { background: var(--surface-2); }
.suggest-item .sg-txt { display: flex; flex-direction: column; line-height: 1.25; }
.suggest-item .sg-txt .muted { font-size: .85rem; }
.suggest-empty { padding: .7rem; color: var(--muted); }
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(-4px); } }

/* Drop zone */
.drop {
  position: relative; text-align: center; cursor: pointer;
  padding: clamp(1.4rem, 4vw, 2.6rem) 1rem clamp(1.4rem, 3vw, 2rem);
  border: 3px dashed color-mix(in srgb, var(--accent) 45%, transparent);
  border-radius: calc(var(--radius) + 10px);
  background: var(--surface); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  transition: transform .45s var(--spring), border-color .2s, background .2s, box-shadow .3s;
  box-shadow: var(--shadow);
}
@supports not (border-color: color-mix(in srgb, red 50%, blue)) { .drop { border-color: var(--border); } }
.drop:hover { transform: translateY(-3px) scale(1.006); border-color: var(--accent); }
.drop:focus-visible { box-shadow: var(--ring), var(--shadow); border-radius: calc(var(--radius) + 10px); }
.drop:active { transform: scale(.99); }
body.dragging-files .drop { border-color: var(--accent-2); transform: scale(1.02); background: var(--surface-solid); }
.drop.has-intent { border-style: solid; border-color: var(--accent-2); }
.drop-title { font-size: clamp(1.3rem, 3vw, 1.8rem); font-weight: 850; margin: .6rem 0 .2rem; }
.drop-hint { color: var(--muted); margin: 0; }
.link-like { color: var(--accent); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.intent { display: inline-flex; align-items: center; gap: .5rem; margin-bottom: .4rem; padding: .3rem .4rem .3rem .9rem; border-radius: 999px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; font-weight: 700; animation: pop .35s var(--spring); }
.intent .chip-x { color: #fff; background: rgba(255, 255, 255, .2); }

.stage { position: relative; width: 150px; height: 160px; margin: 0 auto; }
.stage-goo { position: absolute; inset: -8px -20px; width: calc(100% + 40px); height: calc(100% + 16px); opacity: .9; }
.stage-goo path { fill: url(#lg-brand); fill: var(--accent); opacity: .16; }
.file-icon { position: relative; width: 112px; height: 140px; margin-top: 10px; transform-origin: 50% 90%; animation: bob 4s ease-in-out infinite; filter: drop-shadow(0 14px 18px rgba(76, 29, 149, .25)); }
.file-icon, .fsvg { --c: var(--accent); }
.fi-body { fill: var(--surface-solid); stroke: var(--c); stroke-width: 5; transition: stroke .5s; }
.fi-fold { fill: none; stroke: var(--c); stroke-width: 5; stroke-linejoin: round; transition: stroke .5s; }
.fi-tag { fill: var(--c); transition: fill .5s; }
.fi-label { fill: #fff; font: 900 22px/1 var(--font); letter-spacing: .02em; }
@keyframes bob { 50% { transform: translateY(-8px) rotate(-2deg); } }
.stage.morphing .file-icon { animation: squish 1.3s var(--spring) infinite; }
@keyframes squish {
  0% { transform: scale(1, 1); }
  20% { transform: scale(1.18, .78) rotate(-3deg); }
  40% { transform: scale(.82, 1.2) rotate(3deg); }
  60% { transform: scale(1.08, .92); }
  80% { transform: scale(.96, 1.04); }
  100% { transform: scale(1, 1); }
}
.stage.morphing .stage-goo path { opacity: .35; }
.stage.popped .file-icon { animation: popped .8s var(--spring); }
@keyframes popped { 0% { transform: scale(.6) rotate(-10deg); } 60% { transform: scale(1.18) rotate(4deg); } 100% { transform: scale(1); } }
.stage-sparkles { position: absolute; inset: 0; pointer-events: none; }
.stage-sparkles i { position: absolute; width: 10px; height: 10px; border-radius: 50%; background: var(--accent-2); opacity: 0; }
.stage-sparkles i:nth-child(1) { left: 8%; top: 20%; } .stage-sparkles i:nth-child(2) { right: 6%; top: 12%; background: var(--accent-3); }
.stage-sparkles i:nth-child(3) { left: 0; bottom: 18%; background: #facc15; } .stage-sparkles i:nth-child(4) { right: 0; bottom: 30%; }
.stage-sparkles i:nth-child(5) { left: 50%; top: -4%; background: var(--accent); }
.stage.morphing .stage-sparkles i, .stage.popped .stage-sparkles i { animation: sparkle 1.1s ease-out infinite; }
.stage-sparkles i:nth-child(2n) { animation-delay: .35s !important; } .stage-sparkles i:nth-child(3n) { animation-delay: .7s !important; }
@keyframes sparkle { 0% { opacity: 0; transform: scale(.2); } 30% { opacity: 1; } 100% { opacity: 0; transform: scale(1.6) translateY(-16px); } }

.badges { display: flex; flex-wrap: wrap; justify-content: center; gap: .5rem 1.2rem; list-style: none; padding: 0; margin: 1.1rem 0 1.6rem; color: var(--muted); font-weight: 650; font-size: .92rem; }

/* ------------------------------------------------------------------ */
/* Buttons                                                            */
/* ------------------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .62rem 1.05rem; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface-solid); font-weight: 700; cursor: pointer; white-space: nowrap;
  transition: transform .35s var(--spring), box-shadow .2s, background .2s, opacity .2s;
}
.btn:hover:not(:disabled) { transform: translateY(-2px) scale(1.03); box-shadow: 0 10px 20px -12px var(--accent); }
.btn:active:not(:disabled) { transform: scale(.95); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { color: var(--accent-ink); border-color: transparent; background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.btn.ghost { background: transparent; }
.btn.ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn.sm { padding: .38rem .75rem; font-size: .88rem; }
.btn.big { padding: .85rem 1.5rem; font-size: 1.05rem; }
.icon-btn { border: 0; background: var(--surface-2); width: 2.4rem; height: 2.4rem; border-radius: 50%; cursor: pointer; font-size: 1rem; transition: transform .35s var(--spring); }
.icon-btn:hover { transform: rotate(90deg) scale(1.1); }
.chip-x { border: 0; background: var(--surface-2); color: var(--muted); width: 1.8rem; height: 1.8rem; border-radius: 50%; cursor: pointer; flex: none; transition: transform .3s var(--spring), background .2s; }
.chip-x:hover { transform: scale(1.15) rotate(90deg); background: rgba(239, 68, 68, .15); color: var(--err); }

/* ------------------------------------------------------------------ */
/* Session (one-click)                                                */
/* ------------------------------------------------------------------ */
.session { animation: pop .4s var(--spring); }
.session-head { display: flex; align-items: center; justify-content: space-between; gap: .6rem; flex-wrap: wrap; }
.session-title { margin: 0; font-size: 1.35rem; }
.session-actions { display: flex; gap: .3rem; flex-wrap: wrap; }
.chips { list-style: none; padding: 0; margin: 1rem 0 .6rem; display: flex; flex-wrap: wrap; gap: .55rem; }
.chip {
  display: flex; align-items: center; gap: .6rem; max-width: 100%;
  padding: .4rem .45rem .4rem .45rem; border-radius: 16px; background: var(--surface-solid);
  border: 1px solid var(--border); border-left: 5px solid var(--c, var(--accent)); animation: pop .35s var(--spring);
}
.chip-thumb, .q-thumb { width: 46px; height: 46px; flex: none; display: grid; place-items: center; overflow: hidden; border-radius: 10px; background: var(--surface-2); }
.chip-thumb img, .chip-thumb .thumb-canvas, .q-thumb img, .q-thumb .thumb-canvas { width: 100%; height: 100%; object-fit: cover; }
.fsvg-wrap { display: grid; place-items: center; width: 100%; height: 100%; }
.fsvg { width: 78%; height: 78%; }
.fsvg .fi-label { font-size: 26px; }
.chip-info, .q-name { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.chip-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 15rem; }
.chip-meta { font-size: .8rem; color: var(--muted); }
.detected { color: var(--muted); font-weight: 600; margin: .2rem 0 1rem; }
.targets-title { font-size: 1.05rem; margin: 0 0 .7rem; }
.targets { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 168px), 1fr)); gap: .7rem; }
.target {
  --c: var(--accent);
  position: relative; display: flex; align-items: center; gap: .7rem; text-align: left;
  padding: .75rem .8rem; min-height: 76px; border-radius: 18px; cursor: pointer;
  background: var(--surface-solid); border: 2px solid var(--border); overflow: hidden;
  transition: transform .45s var(--spring), border-color .2s, box-shadow .25s;
  animation: pop .45s var(--spring) backwards;
}
.target:nth-child(2) { animation-delay: .03s; } .target:nth-child(3) { animation-delay: .06s; } .target:nth-child(4) { animation-delay: .09s; }
.target:nth-child(5) { animation-delay: .12s; } .target:nth-child(n+6) { animation-delay: .15s; }
.target::before { content: ""; position: absolute; inset: 0; background: radial-gradient(120% 90% at 0% 0%, var(--c), transparent 60%); opacity: .1; transition: opacity .25s; }
.target:hover:not(:disabled), .target:focus-visible { transform: translateY(-4px) scale(1.035) rotate(-.6deg); border-color: var(--c); box-shadow: 0 16px 28px -16px var(--c); }
.target:hover::before { opacity: .22; }
.target:active:not(:disabled) { transform: scale(.94); }
.target:disabled { opacity: .55; cursor: progress; }
.target.combo { border-style: dashed; border-color: var(--c); }
.target-ico { width: 44px; height: 54px; flex: none; position: relative; }
.target-ico .fsvg { width: 100%; height: 100%; }
.target-txt { display: flex; flex-direction: column; position: relative; min-width: 0; }
.target-label { font-weight: 800; font-size: 1.02rem; line-height: 1.2; }
.target-sub { font-size: .8rem; color: var(--muted); }
.note { min-height: 1.4em; margin: .8rem 0 0; color: var(--muted); font-size: .9rem; }
.finetune { margin-top: 1rem; border-top: 1px dashed var(--border); padding-top: .8rem; }
.finetune > summary { cursor: pointer; font-weight: 750; list-style: none; padding: .3rem 0; border-radius: 8px; }
.finetune > summary::-webkit-details-marker { display: none; }
.finetune > summary::before { content: "\25B8"; display: inline-block; margin-right: .4rem; transition: transform .3s var(--spring); }
.finetune[open] > summary::before { transform: rotate(90deg); }
.finetune-body { padding-top: .8rem; }

/* Options */
.opts { display: grid; gap: .9rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); align-items: start; }
.opt-group { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .6rem .9rem .9rem; margin: 0; min-width: 0; }
.opt-group legend { font-weight: 800; font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); padding: 0 .3rem; }
.opt { display: flex; flex-direction: column; gap: .25rem; margin-top: .55rem; }
.opt > label { font-size: .9rem; font-weight: 650; }
.opt-ctl { display: flex; align-items: center; gap: .5rem; }
.opt-check { flex-direction: row; align-items: center; gap: .5rem; }
.opt-check label { font-weight: 600; font-size: .9rem; }
.opts select, .opts input[type="text"], .opts input[type="number"], .inline-field select, .mode-tabs ~ * select, .tt-actions select {
  width: 100%; padding: .5rem .7rem; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-solid);
}
.opts input[type="range"] { flex: 1; accent-color: var(--accent); }
.opts input[type="checkbox"], .inline-check input { width: 1.15rem; height: 1.15rem; accent-color: var(--accent); }
.opts input[type="color"] { width: 3rem; height: 2.2rem; border: 1px solid var(--border); border-radius: 10px; background: none; padding: 2px; }
.opt-out { min-width: 3.2em; font-weight: 750; text-align: right; font-variant-numeric: tabular-nums; }
.opts-reset { grid-column: 1 / -1; justify-self: start; }
.opts.inline { grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); margin-bottom: .8rem; }
.opts.inline .opt { margin-top: 0; }

/* Progress */
.progress-card { text-align: center; animation: pop .35s var(--spring); }
.morph-row { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-bottom: .8rem; }
.mini-file { --c: var(--accent); display: inline-grid; place-items: center; min-width: 4.4rem; height: 5.2rem; padding: 0 .4rem; border-radius: 10px 22px 10px 10px; background: var(--c); color: #fff; font-weight: 900; box-shadow: 0 12px 22px -12px var(--c); animation: squish 1.4s var(--spring) infinite; }
.mini-file + .morph-arrow + .mini-file { animation-delay: .7s; }
.morph-arrow { display: flex; gap: .3rem; }
.morph-arrow i { width: .6rem; height: .6rem; border-radius: 50%; background: var(--accent); animation: hop 1s ease-in-out infinite; }
.morph-arrow i:nth-child(2) { animation-delay: .15s; background: var(--accent-2); } .morph-arrow i:nth-child(3) { animation-delay: .3s; background: var(--accent-3); }
@keyframes hop { 50% { transform: translateY(-9px); } }
.progress-msg { font-weight: 750; font-size: 1.05rem; min-height: 1.5em; }
.bar { position: relative; height: 14px; border-radius: 999px; background: var(--surface-2); overflow: hidden; border: 1px solid var(--border); }
.bar > span {
  display: block; height: 100%; width: 0; border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-2), var(--accent), var(--accent-3));
  background-size: 200% 100%; animation: barflow 1.6s linear infinite; transition: width .35s var(--ease);
}
.bar > span::after { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(-45deg, rgba(255, 255, 255, .25) 0 8px, transparent 8px 16px); }
@keyframes barflow { to { background-position: -200% 0; } }
.bar.sm { height: 8px; margin-top: .35rem; }
.progress-sub { min-height: 1.3em; margin-top: .5rem; font-size: .9rem; }
.tool-progress { margin: 1rem 0; }

/* Results */
.results { animation: pop .45s var(--spring); }
.results:focus { box-shadow: var(--shadow), var(--ring); }
.res-head { display: flex; gap: .9rem; align-items: center; }
.res-emoji { font-size: 2.6rem; animation: popped .8s var(--spring); }
.res-title { margin: 0 0 .2rem; font-size: clamp(1.15rem, 2.4vw, 1.5rem); }
.outlist, .errlist, .warnlist { list-style: none; padding: 0; margin: 1rem 0 0; display: grid; gap: .55rem; }
.out { display: flex; align-items: center; gap: .8rem; padding: .55rem .6rem; border-radius: 16px; background: var(--surface-solid); border: 1px solid var(--border); flex-wrap: wrap; animation: pop .4s var(--spring) backwards; }
.out-thumb { width: 54px; height: 54px; flex: none; border-radius: 10px; overflow: hidden; display: grid; place-items: center; background: repeating-conic-gradient(var(--surface-2) 0 25%, transparent 0 50%) 50% / 12px 12px; }
.out-thumb img { width: 100%; height: 100%; object-fit: contain; }
.out-info { flex: 1; min-width: 160px; }
.out-name { margin: 0; font-weight: 750; word-break: break-all; }
.out-meta { margin: 0; font-size: .85rem; }
.out-actions { display: flex; gap: .4rem; flex-wrap: wrap; }
.err { padding: .65rem .85rem; border-radius: 14px; background: rgba(239, 68, 68, .1); border: 1px solid rgba(239, 68, 68, .3); color: var(--err); }
.warnlist li { padding: .55rem .85rem; border-radius: 14px; background: rgba(245, 158, 11, .1); border: 1px solid rgba(245, 158, 11, .3); font-size: .92rem; }
.warnlist li::before { content: "\26A0\FE0F  "; }
.res-foot { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: 1.1rem; }
.res-joke { margin: 1rem 0 0; }

/* ------------------------------------------------------------------ */
/* Batch queue                                                        */
/* ------------------------------------------------------------------ */
.queue-toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: 1rem; }
.queue-toolbar .spacer { flex: 1; }
.inline-field { display: inline-flex; align-items: center; gap: .4rem; font-weight: 650; font-size: .92rem; }
.inline-field select { width: auto; padding: .45rem .6rem; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-solid); }
.queue-empty { text-align: center; padding: 2rem 1rem; color: var(--muted); }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; }
.queue th, .support th { text-align: left; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: .5rem; border-bottom: 1px solid var(--border); }
.queue td, .support td { padding: .55rem .5rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.queue td.q-file { display: flex; align-items: center; gap: .6rem; min-width: 220px; }
.queue td.q-size { white-space: nowrap; color: var(--muted); font-variant-numeric: tabular-nums; }
.queue select { padding: .45rem .6rem; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-solid); max-width: 15rem; }
.q-st { min-width: 140px; }
.q-err { margin: .3rem 0 0; color: var(--err); font-size: .85rem; max-width: 26rem; }
.q-actions { white-space: nowrap; text-align: right; }
.q-actions .btn + .btn { margin-left: .3rem; }
.pill { display: inline-block; padding: .15rem .6rem; border-radius: 999px; font-size: .8rem; font-weight: 750; background: var(--surface-2); }
.pill.working { background: rgba(124, 58, 237, .15); color: var(--accent); animation: breathe 1.2s ease-in-out infinite; }
.pill.done { background: rgba(16, 185, 129, .15); color: var(--ok); }
.pill.error { background: rgba(239, 68, 68, .13); color: var(--err); }
@keyframes breathe { 50% { transform: scale(1.07); } }
.queue-overall { margin-top: 1rem; }
.queue-overall p { margin: .4rem 0 0; }

/* ------------------------------------------------------------------ */
/* Toolbox                                                            */
/* ------------------------------------------------------------------ */
.tool-filter { display: flex; flex-direction: column; align-items: center; gap: .7rem; margin-top: 1rem; }
.tool-filter input { width: min(460px, 100%); padding: .7rem 1.1rem; border-radius: 999px; border: 2px solid var(--border); background: var(--surface-solid); }
.tool-filter input:focus-visible { border-color: var(--accent); }
.cat-pills { display: flex; flex-wrap: wrap; justify-content: center; gap: .35rem; }
.pill-btn { border: 1px solid var(--border); background: var(--surface); padding: .35rem .8rem; border-radius: 999px; cursor: pointer; font-weight: 650; font-size: .88rem; transition: transform .3s var(--spring), background .2s; }
.pill-btn:hover { transform: translateY(-2px); }
.pill-btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.toolcat { margin-bottom: 1.6rem; }
.toolcat-title { font-size: 1.25rem; margin: 0 0 .7rem; }
.tools { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); gap: .7rem; }
.tool-card {
  width: 100%; height: 100%; text-align: left; display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto 1fr; gap: .1rem .7rem;
  padding: .9rem 1rem; border-radius: 18px; border: 1px solid var(--border); background: var(--surface); cursor: pointer;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  transition: transform .45s var(--spring), box-shadow .25s, border-color .2s;
}
.tool-card:hover, .tool-card:focus-visible { transform: translateY(-4px) rotate(-.5deg); border-color: var(--accent); box-shadow: var(--shadow); }
.tool-card:active { transform: scale(.96); }
.tool-card.disabled { opacity: .6; border-style: dashed; }
.tool-emoji { grid-row: span 2; font-size: 1.7rem; line-height: 1; padding-top: .1rem; transition: transform .45s var(--spring); }
.tool-card:hover .tool-emoji { transform: scale(1.25) rotate(-10deg); }
.tool-title { font-weight: 800; }
.tool-desc { font-size: .86rem; color: var(--muted); line-height: 1.35; }

/* ------------------------------------------------------------------ */
/* About                                                              */
/* ------------------------------------------------------------------ */
.about-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 1.2rem; align-items: start; }
.prose h2 { font-size: 1.25rem; margin-top: .4rem; }
.prose h3 { font-size: 1.02rem; margin-top: 1.2rem; }
.prose ul { padding-left: 1.2rem; }
.prose li { margin-bottom: .45rem; }
.link-list { list-style: none; padding: 0 !important; }
.link-list a { font-weight: 700; }
.kbd-list { list-style: none; padding: 0 !important; display: grid; gap: .3rem; }
.gratitude { font-style: italic; color: var(--muted); border-left: 3px solid var(--accent-2); padding-left: .8rem; }
.support td:first-child { font-weight: 700; white-space: nowrap; }
.support td:nth-child(2) { white-space: nowrap; }
.support td.muted { font-size: .88rem; min-width: 260px; }
.dot-c { display: inline-block; width: .65rem; height: .65rem; border-radius: 50%; background: var(--c); margin-right: .45rem; vertical-align: middle; }

/* Footer */
.footer { text-align: center; padding: 2rem 1rem 2.6rem; color: var(--muted); border-top: 1px solid var(--border); background: var(--surface); }
.footer p { margin: .3rem auto; max-width: 900px; }
.footer-main b { color: var(--text); }
.footer-sub { font-size: .9rem; }
.footer-grat { font-size: .82rem; font-style: italic; opacity: .85; }

/* ------------------------------------------------------------------ */
/* Modal & tools                                                      */
/* ------------------------------------------------------------------ */
.modal { border: 0; padding: 0; background: transparent; color: var(--text); width: min(760px, 96vw); max-width: 96vw; max-height: 94vh; }
.modal.wide { width: min(1120px, 96vw); }
.modal[open] { animation: modalIn .45s var(--spring); }
.modal::backdrop { background: rgba(20, 10, 40, .45); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
@keyframes modalIn { from { opacity: 0; transform: translateY(20px) scale(.95); } }
.modal-inner { display: flex; flex-direction: column; max-height: 94vh; background: var(--bg); border: 1px solid var(--border); border-radius: calc(var(--radius) + 4px); box-shadow: var(--shadow-lg); overflow: hidden; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .9rem 1.2rem; border-bottom: 1px solid var(--border); background: var(--surface); }
.modal-head h2 { margin: 0; font-size: 1.3rem; }
.modal-body { padding: 1.1rem 1.2rem 1.4rem; overflow: auto; }
.modal-body .results { box-shadow: none; }
.mode-tabs { display: flex; flex-wrap: wrap; gap: .3rem; margin: .8rem 0; padding: .3rem; background: var(--surface-2); border-radius: 16px; }
.mode-tab { border: 0; background: transparent; padding: .45rem .8rem; border-radius: 12px; cursor: pointer; font-weight: 700; font-size: .9rem; color: var(--muted); transition: background .2s, transform .3s var(--spring); }
.mode-tab:hover { color: var(--text); transform: translateY(-1px); }
.mode-tab[aria-selected="true"] { background: var(--surface-solid); color: var(--accent); box-shadow: 0 4px 12px -6px rgba(0, 0, 0, .25); }
.mode-panel { margin-bottom: .8rem; }
.mode-desc { color: var(--muted); }
.mode-actions { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin: .6rem 0 1rem; }
.studio-top { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; justify-content: space-between; }
.studio-bulk { display: flex; flex-wrap: wrap; gap: .3rem; }
.studio-info { margin: 0; font-size: .9rem; }
.studio-empty { text-align: center; padding: 2rem 1rem; border: 2px dashed var(--border); border-radius: var(--radius); color: var(--muted); }
.pagegrid { list-style: none; padding: 0; margin: .5rem 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: .8rem; }
.pcard {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: .3rem;
  padding: .55rem .45rem .45rem; border-radius: 16px; background: var(--surface-solid); border: 2px solid var(--border);
  cursor: grab; transition: transform .35s var(--spring), border-color .2s, opacity .2s, box-shadow .2s; user-select: none;
}
.pcard:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.pcard.dragging { opacity: .4; transform: scale(.95); }
.pcard.selected { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124, 58, 237, .25); }
.pcard.deleted { opacity: .45; border-style: dashed; border-color: var(--err); }
.pcard.deleted .pthumb::after { content: "\2715"; position: absolute; inset: 0; display: grid; place-items: center; font-size: 3rem; color: var(--err); }
.pcard.drop-before { box-shadow: -5px 0 0 0 var(--accent-2); }
.pcard.drop-after { box-shadow: 5px 0 0 0 var(--accent-2); }
.pthumb { --rot: 0deg; position: relative; width: 110px; height: 120px; display: grid; place-items: center; }
.pthumb canvas { max-width: 100%; max-height: 100%; width: auto; height: auto; box-shadow: 0 4px 12px -4px rgba(0, 0, 0, .3); border-radius: 4px; transform: rotate(var(--rot)); transition: transform .45s var(--spring); background: #fff; }
.pthumb-wait { color: var(--muted); font-size: 1.6rem; animation: breathe 1s infinite; }
.pnum { font-weight: 800; font-size: .9rem; }
.psrc { font-size: .72rem; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.psel-wrap { position: absolute; top: .35rem; left: .4rem; z-index: 2; }
.psel { width: 1.1rem; height: 1.1rem; accent-color: var(--accent); cursor: pointer; }
.pctl { display: flex; gap: 2px; flex-wrap: wrap; justify-content: center; }
.pbtn { border: 1px solid var(--border); background: var(--surface); width: 1.75rem; height: 1.75rem; border-radius: 8px; cursor: pointer; font-size: .8rem; padding: 0; transition: transform .3s var(--spring), background .2s; }
.pbtn:hover:not(:disabled) { transform: scale(1.15); background: var(--surface-2); }
.pbtn:disabled { opacity: .35; cursor: default; }
.imglist { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; gap: .45rem; }
.imgrow { display: flex; align-items: center; gap: .7rem; padding: .4rem .6rem; border-radius: 14px; background: var(--surface-solid); border: 1px solid var(--border); cursor: grab; }
.imgrow.drop-before { box-shadow: 0 -4px 0 0 var(--accent-2); }
.imgrow.drop-after { box-shadow: 0 4px 0 0 var(--accent-2); }
.imgrow.dragging { opacity: .4; }
.imgrow .chip-info { flex: 1; }
.imgnum { font-weight: 900; width: 1.6rem; text-align: center; color: var(--accent); }
.empty-row { padding: 1rem; text-align: center; }
.texttools textarea { width: 100%; min-height: 9rem; padding: .8rem; border-radius: 14px; border: 1px solid var(--border); background: var(--surface-solid); font-family: var(--mono); font-size: .9rem; resize: vertical; }
.texttools textarea:focus-visible { border-color: var(--accent); }
.tt-head { display: flex; align-items: center; gap: .8rem; justify-content: space-between; margin: .6rem 0 .3rem; }
.tt-label { font-weight: 800; }
.tt-actions, .tt-outbar { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin: .6rem 0; }
.tt-actions select { width: auto; }
.inline-check { display: inline-flex; align-items: center; gap: .35rem; font-size: .88rem; font-weight: 600; }
.wave-wrap { border-radius: 16px; background: var(--surface-solid); border: 1px solid var(--border); padding: .5rem; margin-bottom: .8rem; }
.wave { width: 100%; height: 140px; display: block; }
.trim-ctl { display: grid; grid-template-columns: auto 1fr; gap: .5rem 1rem; align-items: center; margin-bottom: 1rem; }
.trim-ctl label { font-weight: 700; white-space: nowrap; }
.trim-ctl input[type="number"] { width: 6.5rem; padding: .35rem .5rem; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-solid); }
.trim-ctl input[type="range"] { width: 100%; accent-color: var(--accent); }
.trim-ctl span { grid-column: 1 / -1; }

/* Toasts, overlay, confetti */
.toasts { position: fixed; left: 50%; bottom: max(1rem, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 2000; display: flex; flex-direction: column; gap: .5rem; width: min(560px, calc(100vw - 1.5rem)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: flex-start; gap: .6rem; padding: .75rem .8rem .75rem 1rem; border-radius: 16px; background: var(--surface-solid); color: var(--text); border: 1px solid var(--border); border-left: 5px solid var(--accent); box-shadow: var(--shadow-lg); animation: toastIn .45s var(--spring); }
.toast.ok { border-left-color: var(--ok); } .toast.warn { border-left-color: #f59e0b; } .toast.error { border-left-color: var(--err); }
.toast.out { animation: toastOut .3s ease forwards; }
.toast-msg { flex: 1; font-weight: 600; font-size: .94rem; }
.toast-x { border: 0; background: transparent; cursor: pointer; color: var(--muted); padding: 0 .2rem; font-size: 1rem; }
@keyframes toastIn { from { opacity: 0; transform: translateY(20px) scale(.9); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(12px) scale(.95); } }
.drag-overlay { position: fixed; inset: 0; z-index: 1500; display: grid; place-items: center; background: rgba(124, 58, 237, .18); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); pointer-events: none; }
.drag-bubble { text-align: center; padding: 2rem 2.6rem; border-radius: 40% 60% 55% 45% / 50% 40% 60% 50%; background: var(--surface-solid); box-shadow: var(--shadow-lg); border: 3px dashed var(--accent-2); animation: wobbleBlob 2.2s ease-in-out infinite; font-weight: 850; font-size: 1.3rem; }
.drag-emoji { font-size: 3rem; display: block; }
@keyframes wobbleBlob { 50% { border-radius: 60% 40% 45% 55% / 40% 60% 40% 60%; transform: scale(1.06) rotate(2deg); } }
.confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 3000; }
.noscript { position: fixed; left: 1rem; right: 1rem; bottom: 1rem; z-index: 5000; padding: 1rem; border-radius: 14px; background: #fff3cd; color: #5b4300; text-align: center; font-weight: 700; }

/* Easter eggs */
body.barrel main { animation: barrel 1.2s var(--ease); }
@keyframes barrel { to { transform: rotate(360deg); } }
body.wobble main { animation: wob 2.3s var(--spring); }
@keyframes wob { 15% { transform: skewX(-6deg) scale(1.02, .98); } 35% { transform: skewX(5deg) scale(.98, 1.02); } 55% { transform: skewX(-3deg); } 75% { transform: skewX(2deg); } }

/* ------------------------------------------------------------------ */
/* Responsive                                                          */
/* ------------------------------------------------------------------ */
@media (max-width: 900px) {
  .about-grid { grid-template-columns: 1fr; }
  .tabs { order: 3; width: 100%; margin-left: 0; justify-content: center; }
  .theme-switch { margin-left: auto; }
}
@media (max-width: 640px) {
  .brand-name { font-size: 1.15rem; }
  .tab { padding: .45rem .65rem; font-size: .9rem; }
  .search-kbd { display: none; }
  .queue thead { display: none; }
  .queue, .queue tbody, .queue tr, .queue td { display: block; width: 100%; }
  .queue tr { border: 1px solid var(--border); border-radius: 16px; padding: .5rem; margin-bottom: .6rem; background: var(--surface-solid); }
  .queue td { border: 0; padding: .3rem .2rem; }
  .queue td.q-file { min-width: 0; }
  .queue select { max-width: 100%; width: 100%; }
  .q-actions { text-align: left; }
  .chip-name { max-width: 11rem; }
  .pagegrid { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); }
  .pthumb { width: 96px; height: 106px; }
  .modal, .modal.wide { width: 100vw; max-width: 100vw; max-height: 100vh; margin: 0; }
  .modal-inner { max-height: 100vh; border-radius: 0; }
  .res-head { align-items: flex-start; }
  .out-actions { width: 100%; }
}
@media (max-width: 380px) {
  .targets { grid-template-columns: 1fr 1fr; }
  .target { flex-direction: column; text-align: center; padding: .7rem .4rem; }
  .target-txt { align-items: center; }
  .stage { transform: scale(.85); }
}
@media (min-width: 1800px) { html { font-size: 18px; } main { width: min(1400px, 100%); } }
@media (min-width: 2400px) { html { font-size: 22px; } main { width: min(1700px, 100%); } }
@media (min-width: 3400px) { html { font-size: 28px; } main { width: min(2200px, 100%); } }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; animation-delay: 0s !important; transition-duration: .001ms !important; }
  .mesh, .blob { animation: none !important; }
}
@media print {
  .bg, .topbar, .footer, .toasts, .drop, .search, .badges { display: none !important; }
}
