:root {
  --bg: #07070a;
  --side: #0b0b10;
  --card: #101014;
  --ink: #f4f4f5;
  --muted: #a1a1aa;
  --line: #27272f;
  --accent: #8b5cf6;
  --ok: #34d399;
  --bad: #fb7185;
  --run: #c4b5fd;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
html, body { margin: 0; min-height: 100%; }
body {
  display: flex;
  min-height: 100vh;
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(900px 420px at 80% -10%, rgba(139, 92, 246, 0.16), transparent 50%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  animation: fadein 0.5s ease;
}

@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes hatspin { from { transform: rotateX(16deg) rotateY(-22deg); } to { transform: rotateX(16deg) rotateY(338deg); } }
@keyframes pulse { 50% { opacity: 0.45; } }
@keyframes border-fall {
  0% { background-position: 0 -40%; }
  100% { background-position: 0 140%; }
}

.side {
  position: sticky;
  top: 0;
  width: 228px;
  height: 100vh;
  padding: 22px 16px;
  border-right: 1px solid var(--line);
  background: var(--side);
  display: flex;
  flex-direction: column;
}
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
  margin-bottom: 28px;
}
.logo-mark {
  width: 34px;
  height: 34px;
  object-fit: contain;
  padding: 4px;
  border-radius: 10px;
  background: #f4f4f5;
}
.nav-label {
  margin: 0 8px 8px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.side nav { display: grid; gap: 4px; flex: 1; }
.side-user { display: none; }
.side-user strong { display: block; font-size: 13px; }
.side-user small { display: block; color: var(--muted); font-size: 12px; margin: 4px 0 10px; }
.side-user button {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}
.side-user button:hover { color: var(--ink); }
.side nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 12px;
  border-radius: 10px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
  transition: 0.18s ease;
}
.side nav a svg {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.side nav a:hover { color: var(--ink); background: #16161d; }
.side nav a.on { background: var(--accent); color: #fff; }

.app { flex: 1; min-width: 0; padding: 24px 28px 56px; }

.hero-panel,
.stats article,
.drop,
.fn-card,
.card,
.editor {
  --beam: 3.8s;
  --beam-delay: 0s;
  position: relative;
}
.hero-panel::before,
.stats article::before,
.drop::before,
.fn-card::before,
.card::before,
.editor::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  pointer-events: none;
  z-index: 2;
  background: linear-gradient(
    180deg,
    transparent 0%,
    transparent 42%,
    #6d28d966 47%,
    #e9d5ff 50%,
    #a78bfa 53%,
    transparent 58%,
    transparent 100%
  );
  background-size: 100% 260%;
  background-repeat: no-repeat;
  animation: border-fall var(--beam) linear infinite;
  animation-delay: var(--beam-delay);
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
}
.hero-panel { --beam: 5.4s; }
.drop { --beam: 4.6s; --beam-delay: 0.4s; }
.card { --beam: 5s; --beam-delay: 0.8s; }
.stats article:nth-child(1) { --beam-delay: 0s; }
.stats article:nth-child(2) { --beam-delay: 0.55s; }
.stats article:nth-child(3) { --beam-delay: 1.1s; }
.stats article:nth-child(4) { --beam-delay: 1.65s; }
.fn-card:nth-child(odd) { --beam-delay: 0.35s; }
.fn-card:nth-child(even) { --beam-delay: 1.15s; }

.hero-panel {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 28px;
  align-items: center;
  margin-bottom: 22px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(180deg, #14141a, #0e0e13);
}
.lede { margin: 8px 0 0; color: var(--muted); max-width: 46ch; line-height: 1.5; }
.muted { margin: 0 0 6px; color: var(--muted); font-size: 13px; }
h1 { margin: 0; font-size: 30px; letter-spacing: -0.04em; }

.hat-stage {
  position: relative;
  height: 196px;
  perspective: 1100px;
  display: grid;
  place-items: center;
}
.hat-stage::before {
  content: "";
  position: absolute;
  width: 160px;
  height: 90px;
  border-radius: 50%;
  background: radial-gradient(circle, #d946ef44, transparent 70%);
  filter: blur(8px);
}
.hat-shadow {
  width: 150px;
  height: 22px;
  border-radius: 50%;
  background: radial-gradient(closest-side, #c026d333, transparent 70%);
  transform: translateY(78px);
  filter: blur(4px);
}
.logo3d {
  position: relative;
  width: 168px;
  height: 168px;
  transform-style: preserve-3d;
  transform: rotateX(16deg) rotateY(-26deg);
  animation: logosway 7s ease-in-out infinite, float 4.2s ease-in-out infinite;
}
.logo3d-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
}
.logo3d-layer.front {
  filter: drop-shadow(0 0 16px #d946ef99) drop-shadow(0 8px 22px #000c);
}
.logo3d-layer.depth {
  filter: brightness(0) saturate(100%) invert(18%) sepia(80%) saturate(2200%) hue-rotate(250deg);
}
@keyframes logosway {
  0%, 100% { transform: rotateX(16deg) rotateY(-26deg); }
  50% { transform: rotateX(10deg) rotateY(22deg); }
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
.stats article {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  transition: transform 0.2s ease, border-color 0.2s ease;
}
.stats article:hover { transform: translateY(-2px); border-color: #3f3f46; }
.stats span, .stats small { color: var(--muted); font-size: 12px; }
.stats strong { display: block; margin: 8px 0 4px; font-size: 28px; letter-spacing: -0.04em; }

.drop, .card, .editor, .film li {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
}
.drop {
  display: grid;
  place-items: center;
  gap: 6px;
  min-height: 168px;
  text-align: center;
  padding: 28px 20px;
  cursor: pointer;
  border-style: dashed;
  transition: 0.2s ease;
}
.drop.drag, .drop:hover { border-color: var(--accent); background: #161022; }
.drop-kicker { color: var(--accent); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; }
.drop strong { font-size: 20px; }
.drop span { color: var(--muted); font-size: 13px; }
.drop input { display: none; }

#config {
  margin-top: 16px;
  animation: fadein 0.35s ease;
}
.config-kicker {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.fn-group { margin-bottom: 22px; }
.fn-group h3 {
  margin: 0 0 12px;
  color: #d4d4dc;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.fn-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: stretch;
  min-width: 0;
}
.fn-grid > * { min-width: 0; }
.fn-card {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 0 14px;
  min-height: 118px;
  padding: 16px 18px;
  border: 1px solid #262632;
  border-radius: 18px;
  background: linear-gradient(180deg, #16161e, #101016);
  animation: rise 0.35s ease;
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}
.fn-card > div { min-width: 0; }
.fn-card > .toggle { margin-top: 0; }
.fn-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: linear-gradient(180deg, #4c1d95, #2e1065);
  box-shadow: inset 0 0 0 1px #c4b5fd44;
}
.fn-icon svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: #f5f3ff;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.fn-card:hover {
  border-color: #7c3aed;
  box-shadow: 0 0 0 1px #7c3aed33;
}
.fn-card:has(.toggle input:checked) {
  border-color: #8b5cf6;
  background: linear-gradient(180deg, #2a1760, #140e28);
  box-shadow: 0 0 0 1px #8b5cf655, 0 10px 24px #8b5cf61f;
}
.fn-card:has(.toggle input:checked) .fn-icon {
  background: #8b5cf6;
  box-shadow: none;
}
.fn-card:has(.toggle input:checked) .fn-icon svg { stroke: #fff; }
.fn-card.wide { grid-column: 1 / -1; }
.fn-card.stack {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}
.fn-card.stack > .fn-icon { grid-column: 1; grid-row: 1; }
.fn-card.stack > div { grid-column: 2; }
#pitch-box { margin-top: 10px; }
.fn-card strong {
  display: block;
  color: #fff;
  font-size: 14px;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.fn-card p {
  margin: 6px 0 0;
  color: #9b9ba8;
  font-size: 12px;
  line-height: 1.45;
}
@media (max-width: 640px) {
  .fn-grid { grid-template-columns: 1fr; }
}
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
.card { padding: 18px; }
.label {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.seg, .chips { display: flex; flex-wrap: wrap; gap: 8px; }
.seg-btn, .chip, button, .ghost {
  min-height: 42px;
  border: 0;
  border-radius: 11px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
  transition: 0.16s ease;
}
.seg-btn, .chip {
  flex: 1;
  background: #09090b;
  color: var(--ink);
  border: 1px solid var(--line);
}
.seg-btn:hover, .chip:hover, .ghost:hover { border-color: #52525b; }
.seg-btn.on, .chip.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.seg-btn:active, .chip:active, #submit:active { transform: scale(0.98); }

#pitch-box { margin-top: 10px; }
.row { display: flex; justify-content: space-between; margin-bottom: 8px; color: var(--muted); }
output { color: var(--accent); font-weight: 700; }
input[type="range"] { width: 100%; accent-color: var(--accent); height: 32px; }
.hint { margin: 12px 0 0; color: var(--muted); font-size: 13px; line-height: 1.45; }

.opt {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  min-height: 46px;
  padding: 4px 0;
  border-bottom: 1px solid #1d1d24;
}
.opt:last-of-type { border-bottom: 0; }
.toggle { position: relative; width: 44px; height: 26px; flex: none; }
.toggle input { position: absolute; inset: 0; opacity: 0; cursor: pointer; z-index: 2; }
.toggle i {
  position: absolute;
  inset: 0;
  border-radius: 99px;
  background: #3f3f46;
  transition: 0.2s ease;
}
.toggle i::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  transition: 0.2s ease;
  box-shadow: 0 2px 6px #0006;
}
.toggle input:checked + i { background: var(--accent); }
.toggle input:checked + i::after { transform: translateX(18px); }
.toggle input:focus-visible + i { outline: 2px solid #c4b5fd; }

#submit {
  width: 100%;
  margin-top: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--accent);
  color: #fff;
}
#submit:disabled { opacity: 0.35; cursor: not-allowed; }
#submit[data-busy="1"]::after {
  content: "";
  width: 16px;
  height: 16px;
  border: 2px solid #ffffff44;
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

#editor { margin-top: 16px; }
.editor {
  overflow: hidden;
  background: #0a0a0f;
}
.editor-chrome {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.editor-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px #8b5cf6;
}
#preview-kind { margin-left: auto; }
.editor-stage {
  min-height: 340px;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(180deg, #121218cc, #0a0a0ecc),
    repeating-conic-gradient(#1a1a22 0% 25%, #101016 0% 50%) 50% / 18px 18px;
}
.preview-frame {
  position: relative;
  overflow: hidden;
  max-width: min(100%, 760px);
  border-radius: 12px;
  box-shadow: 0 24px 60px #000a;
  background: #000;
}
.preview-frame img,
.preview-frame video {
  display: block;
  max-width: 100%;
  max-height: 440px;
  transform-origin: center center;
  transition: transform 0.35s ease, filter 0.35s ease;
}
.preview-frame video { width: min(100%, 760px); background: #000; }
.fx-grain,
.fx-grid,
.fx-pixels {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.fx-grain {
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}
.preview-frame.is-gaussian .fx-grain,
.preview-frame.is-noise .fx-grain { opacity: 0.28; }
.fx-grid {
  background-image:
    linear-gradient(#ffffff18 1px, transparent 1px),
    linear-gradient(90deg, #ffffff18 1px, transparent 1px),
    radial-gradient(#ffffff30 1px, transparent 1.2px);
  background-size: 22px 22px, 22px 22px, 11px 11px;
}
.preview-frame.is-overlay .fx-grid { opacity: 1; }
.fx-pixels::before,
.fx-pixels::after {
  content: "";
  position: absolute;
  width: 3px;
  height: 3px;
  background: #fff;
  mix-blend-mode: difference;
}
.fx-pixels::before { top: 0; left: 0; }
.fx-pixels::after { right: 0; bottom: 0; }
.preview-frame.is-pixels .fx-pixels { opacity: 1; }
.fx-badges {
  position: absolute;
  left: 10px;
  top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  pointer-events: none;
}
.fx-badges span {
  padding: 4px 8px;
  border-radius: 999px;
  background: #120c1ccc;
  color: #e9d5ff;
  font-size: 11px;
  letter-spacing: 0.02em;
}
.fx-toasts {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 80;
  display: grid;
  gap: 8px;
  width: min(420px, calc(100vw - 28px));
}
.fx-toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  border: 1px solid #3b2a63;
  border-radius: 16px;
  background: #120c1cf2;
  box-shadow: 0 18px 40px #0000008a;
  color: #f4f4f5;
  animation: toast-in 0.32s ease;
}
.fx-toast.off { border-color: #4a1d27; }
.fx-toast i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px #8b5cf6;
  flex: none;
}
.fx-toast.off i { background: #fb7185; box-shadow: 0 0 10px #fb7185; }
.fx-toast strong { display: block; font-size: 13px; }
.fx-toast small { color: var(--muted); font-size: 12px; }
.fx-toast.out { animation: toast-out 0.28s ease forwards; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateY(10px); }
}
.editor-stage audio { width: min(100%, 420px); }
.audio-preview {
  display: grid;
  place-items: center;
  gap: 16px;
  color: var(--muted);
}
.audio-disc {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, #111 0 18px, transparent 19px),
    repeating-radial-gradient(circle, #3f3f46 0 2px, #18181b 3px 6px);
  box-shadow: 0 0 24px #8b5cf644;
}
.editor-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  background: #0e0e14;
}
.editor-copy { min-width: 0; }
.editor-copy strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.trash {
  width: 42px;
  min-width: 42px;
  min-height: 42px;
  display: grid;
  place-items: center;
  padding: 0;
  color: #fb7185;
  background: #1a1014;
  border: 1px solid #4a1d27;
  border-radius: 11px;
}
.trash svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.trash:hover { background: #3f1822; }
.trash:disabled { opacity: 0.35; cursor: not-allowed; }
.film {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: flex;
  gap: 8px;
  overflow-x: auto;
}
.film li {
  position: relative;
  width: 96px;
  flex: none;
  padding: 0;
  overflow: hidden;
  cursor: pointer;
}
.film li.on { outline: 2px solid var(--accent); outline-offset: 0; }
.film li img,
.film li video {
  width: 100%;
  height: 74px;
  object-fit: cover;
  display: block;
  background: #09090b;
}
.film .thumb-audio,
.film .thumb-file {
  height: 74px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 11px;
  background: #09090b;
}
.film .trash {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 28px;
  min-width: 28px;
  min-height: 28px;
  z-index: 3;
}
.film .trash svg { width: 14px; height: 14px; }
.film .badge {
  position: absolute;
  left: 6px;
  bottom: 6px;
  padding: 2px 6px;
  border-radius: 6px;
  background: #000a;
  font-size: 9px;
}
.download { color: #c4b5fd; font-weight: 650; text-decoration: none; }
.meta { color: var(--muted); font-size: 13px; margin-top: 4px; }
.badge { font-size: 11px; text-transform: uppercase; color: var(--run); }
.badge.running { position: relative; padding-left: 16px; }
.badge.running::before {
  content: "";
  position: absolute;
  left: 0;
  top: 3px;
  width: 10px;
  height: 10px;
  border: 2px solid #c4b5fd55;
  border-top-color: #c4b5fd;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.badge.done { color: var(--ok); }
.badge.error { color: var(--bad); }

.progress { display: flex; align-items: center; gap: 12px; margin-top: 14px; }
.progress-track { flex: 1; height: 8px; background: #18181b; overflow: hidden; border-radius: 99px; }
.progress-bar {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, #6d28d9, #a78bfa);
  box-shadow: 0 0 16px #8b5cf688;
  transition: width 0.25s ease;
}
#progress-label { min-width: 92px; font-size: 12px; color: var(--muted); }

.actions { display: flex; gap: 12px; align-items: center; margin-top: 14px; }
.ghost {
  display: inline-flex;
  align-items: center;
  padding: 0 16px;
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
  text-decoration: none;
}
.text { background: transparent; color: var(--muted); }

.media-opts { margin-top: 12px; }
.verify { margin-top: 18px; }
.drop.mini { min-height: 100px; margin-top: 10px; }
.inspect { margin-top: 12px; }
.inspect ul { margin: 8px 0 0; padding-left: 18px; }
.inspect li.ok { color: var(--ok); }
.inspect li.bad { color: var(--bad); }
.inspect-ok { color: var(--ok); font-weight: 650; }
.inspect-bad { color: var(--bad); font-weight: 650; }
.leftover { color: var(--muted); font-size: 12px; }

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 18px;
}
.log-filter {
  display: grid;
  gap: 8px;
  min-width: min(360px, 100%);
}
.log-filter span {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.log-filter select {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #0c0c10;
  color: var(--ink);
  font: inherit;
}
.log-filter select:focus {
  outline: 2px solid #8b5cf666;
  border-color: #8b5cf6;
}
.ghost.accent {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.short-form {
  padding: 18px;
  margin-bottom: 16px;
}
.field { display: grid; gap: 8px; }
.field.wide { grid-column: 1 / -1; }
.field > span {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.field input:not([type="checkbox"]),
.table-tools input {
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #09090b;
  color: var(--ink);
  font: inherit;
}
.field input:not([type="checkbox"]):focus,
.table-tools input:focus {
  outline: 2px solid #8b5cf666;
  border-color: var(--accent);
}
.pick-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 0;
}
.pick-tags:empty { display: none; }
.mini-flag {
  width: 18px;
  height: 12px;
  object-fit: cover;
  border-radius: 2px;
  box-shadow: 0 0 0 1px #ffffff22;
  flex: none;
}
.pick-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 8px 0 10px;
  border: 1px solid #3b2a63;
  border-radius: 12px;
  background: #1a1230;
  color: #e9d5ff;
  font-size: 12px;
}
.pick-tag em,
.pick-list button em {
  font-style: normal;
}
.pick-tag button {
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #2a1d44;
  color: #c4b5fd;
  cursor: pointer;
}
.pick-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 188px;
  overflow: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #0c0c10;
}
.pick-list button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 12px 0 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #101016;
  color: var(--ink);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}
.pick-list button:hover,
.pick-list button.on {
  border-color: #8b5cf6;
  background: #1a1230;
  color: #e9d5ff;
  transform: translateY(-1px);
}
.device-picks {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  width: 100%;
}
.device-card {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 16px 10px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background:
    linear-gradient(180deg, #14141b, #0c0c10);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}
.device-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.device-icon {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: #1a1230;
  box-shadow: inset 0 0 0 1px #8b5cf622;
}
.device-icon svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: #c4b5fd;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.device-card strong {
  font-size: 13px;
  letter-spacing: -0.02em;
}
.device-card small {
  color: var(--muted);
  font-size: 11px;
}
.device-card:hover {
  border-color: #5b21b6;
  transform: translateY(-2px);
}
.device-card:has(input:checked) {
  border-color: #8b5cf6;
  background: linear-gradient(180deg, #24184a, #140e24);
  box-shadow: 0 0 0 1px #8b5cf655, 0 10px 24px #8b5cf61f;
}
.device-card:has(input:checked) .device-icon {
  background: #8b5cf6;
}
.device-card:has(input:checked) .device-icon svg { stroke: #fff; }
.device-card:has(input:checked) small { color: #c4b5fd; }
@media (max-width: 720px) {
  .device-picks { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.rule-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #0c0c11;
  cursor: pointer;
}
.rule-card input {
  width: 16px;
  height: 16px;
  margin: 0;
  flex: 0 0 16px;
  accent-color: var(--accent);
}
.rule-card .rule-icon {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: #1a1230;
}
.rule-card .rule-icon svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: #8b5cf6;
  stroke-width: 1.8;
  stroke-linecap: round;
}
.rule-card span:last-child {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.rule-card strong {
  font-size: 14px;
  font-weight: 600;
}
.rule-card small {
  color: var(--muted);
  font-size: 12px;
}
.rule-card:has(input:checked) {
  border-color: #8b5cf655;
  background: #120e1c;
}
.rule-card:has(+ .lang-box:not([hidden])) {
  border-radius: 16px 16px 0 0;
  border-bottom-color: transparent;
}
.lang-box {
  margin-top: 0;
  padding: 14px 16px 16px;
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 16px 16px;
  background: #0a0a0f;
}
.lang-box .hint { margin: 0 0 12px; }
.lang-picks {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  width: 100%;
}
@media (max-width: 640px) {
  .lang-picks { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.short-form .lang-card {
  position: relative;
  display: grid;
  gap: 3px;
  min-height: 58px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, #14141b, #0c0c10);
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.short-form .lang-card input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  min-height: 0;
  padding: 0;
  margin: 0;
  pointer-events: none;
}
.short-form .lang-card b {
  color: #a78bfa;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
}
.short-form .lang-card em {
  font-style: normal;
  font-size: 13px;
  color: var(--ink);
}
.short-form .lang-card:hover {
  border-color: #5b21b6;
}
.short-form .lang-card:has(input:checked) {
  border-color: #8b5cf6;
  background: linear-gradient(180deg, #24184a, #140e24);
  box-shadow: 0 0 0 1px #8b5cf655;
}
.short-form .lang-card:has(input:checked) b { color: #ddd6fe; }
#save-link {
  position: relative;
  z-index: 3;
  width: 100%;
  margin-top: 14px;
  background: var(--accent);
  color: #fff;
}
.short-form .field input,
.short-form #save-link { pointer-events: auto; }
.table-wrap { padding: 16px; overflow: auto; }
.table-tools {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.table-tools input { flex: 1; max-width: 360px; }
.data { width: 100%; border-collapse: collapse; }
.data th,
.data td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.data th {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.clip {
  max-width: 320px;
  overflow: hidden;
}
.clip .bot-dest {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-actions { display: flex; align-items: center; gap: 8px; }
.row-actions .chip { flex: none; min-height: 34px; padding: 0 12px; }
.row-actions .trash { width: 34px; min-width: 34px; min-height: 34px; }

.logs-stats { margin-bottom: 16px; }
@media (min-width: 1100px) {
  .logs-stats { grid-template-columns: repeat(6, 1fr); }
}
.chart-card { padding: 0; margin-bottom: 16px; overflow: hidden; }
.chart-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 18px 20px 12px;
}
.chart-head h2 {
  margin: 4px 0 0;
  font-size: 18px;
  letter-spacing: -0.03em;
}
.chart-tools {
  display: flex;
  align-items: flex-end;
  gap: 16px;
}
.chart-tabs {
  display: flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #0c0c10;
}
.chart-tabs button {
  min-height: 34px;
  padding: 0 12px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.chart-tabs button.on {
  background: #1a1230;
  color: #e9d5ff;
}
.chart-total { text-align: right; }
.chart-total strong {
  display: block;
  font-size: 28px;
  line-height: 1;
  letter-spacing: -0.04em;
}
.chart-total span,
.chart-meta {
  color: var(--muted);
  font-size: 12px;
}
.chart-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 0 20px 10px;
  border-bottom: 1px solid var(--line);
}
.chart-body {
  position: relative;
  padding: 16px 16px 10px;
  min-height: 280px;
}
.chart-plot {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 8px;
  height: 248px;
}
.chart-y {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-end;
  color: #8b8b96;
  font-size: 10px;
  padding-bottom: 22px;
}
.chart-cols {
  display: flex;
  align-items: stretch;
  gap: 4px;
  height: 100%;
}
.chart-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
}
.chart-col i {
  display: block;
  width: 100%;
  max-width: 28px;
  border-radius: 8px 8px 3px 3px;
  background: linear-gradient(180deg, #c4b5fd, #7c3aed);
  box-shadow: 0 0 0 1px #ffffff10 inset;
  transition: filter 0.15s ease, transform 0.15s ease;
}
.chart-col.is-empty i {
  min-height: 4px;
  background: #27272f;
  box-shadow: none;
}
.chart-col:hover i,
.chart-col.on i {
  filter: brightness(1.18);
  transform: translateY(-2px);
}
.chart-col span {
  color: #8b8b96;
  font-size: 10px;
  white-space: nowrap;
}
.chart-tip {
  position: absolute;
  z-index: 5;
  min-width: 180px;
  padding: 10px 12px;
  border: 1px solid #3b2a63;
  border-radius: 12px;
  background: #120c1c;
  box-shadow: 0 12px 30px #00000080;
  color: #f4f4f5;
  font-size: 12px;
  pointer-events: none;
}
.chart-tip strong { display: block; margin-bottom: 6px; font-size: 13px; }
.chart-tip p { margin: 3px 0 0; color: #c4b5fd; }
.chart-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  pointer-events: none;
}
.country-cell {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.country-cell .flag {
  width: 22px;
  height: 16px;
  object-fit: cover;
  border-radius: 3px;
  box-shadow: 0 0 0 1px #ffffff14;
}
.country-cell {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.country-cell .flag {
  width: 22px;
  height: 16px;
  object-fit: cover;
  border-radius: 3px;
}
.hit-wrap { padding: 16px; }
.hit-list {
  display: grid;
  gap: 10px;
}
.hit-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 40px;
  padding: 16px 18px 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #0c0c11;
}
.hit-main,
.hit-side {
  display: grid;
  gap: 8px;
  align-content: start;
}
.hit-side { justify-items: start; min-width: 120px; }
.hit-card p {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: #d4d4d8;
  font-size: 13px;
  min-width: 0;
}
.hit-card p span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hit-card svg {
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
  fill: none;
  stroke: #71717a;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.hit-card .mini-flag {
  width: 18px;
  height: 12px;
  border-radius: 2px;
  object-fit: cover;
}
.hit-dot {
  width: 12px;
  height: 12px;
  flex: 0 0 12px;
  border: 2px solid #8b5cf6;
  border-radius: 50%;
}
.hit-card small {
  grid-column: 1 / -1;
  color: #52525b;
  font-size: 11px;
}
@media (max-width: 640px) {
  .hit-card { grid-template-columns: 1fr; gap: 10px; }
}

@media (max-width: 900px) {
  html, body { overflow-x: hidden; }
  body { display: block; }
  .side {
    position: sticky;
    top: 0;
    z-index: 20;
    width: auto;
    height: auto;
    padding: max(10px, env(safe-area-inset-top)) 12px 10px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .logo { margin-bottom: 10px; }
  .nav-label { display: none; }
  .side nav { grid-template-columns: repeat(3, 1fr); flex: none; }
  .side nav a {
    min-height: 40px;
    justify-content: center;
    font-size: 13px;
    padding: 0 8px;
  }
  .side-user {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    padding-top: 10px;
  }
  .side-user strong { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .side-user small { margin: 0; }
  .side-user button { width: auto; padding: 0 12px; }
  .hero-panel, .stats { grid-template-columns: 1fr; }
  .app { padding: 16px 14px max(40px, env(safe-area-inset-bottom)); }
  .logo3d { animation: float 4.2s ease-in-out infinite; }
  .page-head { align-items: stretch; }
  .page-head .ghost { width: 100%; }
  .chart-head, .chart-tools, .table-tools { flex-direction: column; align-items: stretch; }
  .table-tools input { max-width: none; }
  .clip { max-width: 180px; }
  .fn-grid { grid-template-columns: 1fr; }
  input, select, textarea { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .hero-panel::before,
  .stats article::before,
  .drop::before,
  .fn-card::before,
  .card::before,
  .editor::before {
    animation: none;
    opacity: 0.35;
    background-position: 0 50%;
  }
}
