:root {
  --ink: #141414;
  --panel: rgba(30, 30, 30, 0.6);
  --text: #e8e8e8;
  --muted: #969696;
  --line: rgba(255, 255, 255, 0.08);
  --line2: rgba(255, 255, 255, 0.16);
  --blur: blur(16px) saturate(1.15);
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--ink);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.bg {
  position: fixed;
  inset: -20%;
  z-index: -1;
  background:
    radial-gradient(40% 40% at 22% 28%, rgba(255, 255, 255, 0.06), transparent 70%),
    radial-gradient(46% 46% at 78% 72%, rgba(255, 255, 255, 0.045), transparent 70%),
    radial-gradient(34% 34% at 60% 20%, rgba(0, 0, 0, 0.5), transparent 72%);
  filter: blur(8px);
  animation: drift 22s var(--ease) infinite alternate;
}

@keyframes drift {
  0%   { transform: translate3d(-2%, -1%, 0) scale(1.02); }
  50%  { transform: translate3d(2%, 1.5%, 0) scale(1.06); }
  100% { transform: translate3d(-1%, 2%, 0) scale(1.03); }
}

.top {
  max-width: 1180px;
  margin: 0 auto;
  padding: 38px 28px 8px;
  animation: rise 0.7s var(--ease) both;
}

.brand { display: flex; align-items: center; gap: 16px; }

.brand-mark {
  width: 52px; height: 52px;
  display: grid; place-items: center;
  font-weight: 700; font-size: 26px;
  letter-spacing: -1px;
  color: var(--text);
  background: var(--panel);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border: 1px solid var(--line2);
  border-radius: 14px;
  transition: transform 0.4s var(--ease), border-color 0.4s var(--ease);
}
.brand-mark:hover { transform: translateY(-3px) rotate(-3deg); border-color: rgba(255, 255, 255, 0.3); }

.brand-text h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 650;
  letter-spacing: 0.3px;
}
.brand-text p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13.5px;
}

.stage {
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px 28px 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
}

.panel {
  position: relative;
  background: var(--panel);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 20px 20px 22px;
  display: flex;
  flex-direction: column;
  min-height: 460px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  animation: rise 0.8s var(--ease) both;
  transition: border-color 0.45s var(--ease), transform 0.45s var(--ease);
}
#inPanel { animation-delay: 0.06s; }
#outPanel { animation-delay: 0.16s; }
.panel:hover { border-color: var(--line2); transform: translateY(-2px); }

@keyframes rise {
  from { opacity: 0; transform: translateY(22px); }
  to   { opacity: 1; transform: translateY(0); }
}

.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.panel-head h2 {
  margin: 0; font-size: 14px; font-weight: 600;
  letter-spacing: 1.4px; text-transform: uppercase; color: var(--muted);
}

.badge {
  font-size: 12px; color: var(--muted);
  padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--line);
  transition: color 0.4s var(--ease), border-color 0.4s var(--ease);
}

.editor {
  flex: 1;
  width: 100%;
  resize: none;
  background: rgba(0, 0, 0, 0.32);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  font-family: "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.55;
  outline: none;
  transition: border-color 0.4s var(--ease), box-shadow 0.4s var(--ease), background 0.4s var(--ease);
}
.editor::placeholder { color: rgba(150, 150, 150, 0.7); }
.editor:focus {
  border-color: rgba(255, 255, 255, 0.32);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.06);
  background: rgba(0, 0, 0, 0.4);
}
.editor.out {
  white-space: pre-wrap;
  word-break: break-word;
  overflow: auto;
  margin: 0;
}
.editor.out code { font: inherit; color: var(--text); }

.controls {
  display: flex; align-items: center; gap: 16px;
  margin-top: 16px; flex-wrap: wrap;
}
.field { display: flex; align-items: center; gap: 10px; }
.field-label {
  font-size: 12px; letter-spacing: 1px; text-transform: uppercase; color: var(--muted);
}

.stepper {
  display: inline-flex; align-items: center;
  border: 1px solid var(--line);
  border-radius: 10px; overflow: hidden;
  background: rgba(0, 0, 0, 0.28);
}
.step {
  width: 36px; height: 36px;
  background: transparent; color: var(--text);
  border: none; cursor: pointer; font-size: 18px; line-height: 1;
  transition: background 0.3s var(--ease), transform 0.2s var(--ease);
}
.step:hover { background: rgba(255, 255, 255, 0.1); }
.step:active { transform: scale(0.9); }
.stepval {
  width: 44px; height: 36px;
  text-align: center; border: none; outline: none;
  background: transparent; color: var(--text);
  font-size: 15px; font-weight: 600;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
}

.toggle { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.track {
  width: 46px; height: 26px; border-radius: 999px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--line);
  position: relative;
  transition: background 0.4s var(--ease), border-color 0.4s var(--ease);
}
.knob {
  position: absolute; top: 2px; left: 2px;
  width: 20px; height: 20px; border-radius: 50%;
  background: rgba(232, 232, 232, 0.85);
  transition: transform 0.4s var(--ease), background 0.4s var(--ease);
}
.toggle input:checked + .track {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.34);
}
.toggle input:checked + .track .knob {
  transform: translateX(20px);
  background: #fff;
}
.toggle input:focus-visible + .track { box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.12); }
.toggle-label { font-size: 13px; color: var(--muted); transition: color 0.4s var(--ease); }
.toggle:hover .toggle-label { color: var(--text); }

.btn {
  font: inherit; cursor: pointer;
  border-radius: 11px; padding: 10px 20px;
  border: 1px solid var(--line2);
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  transition: transform 0.25s var(--ease), background 0.35s var(--ease), border-color 0.35s var(--ease), opacity 0.35s var(--ease);
}
.btn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.14); transform: translateY(-2px); border-color: rgba(255, 255, 255, 0.32); }
.btn:active:not(:disabled) { transform: translateY(0) scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn.primary {
  margin-left: auto;
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.28);
  font-weight: 600; letter-spacing: 0.4px;
}
.btn.ghost { background: transparent; }

.status {
  margin-top: 12px; font-size: 12.5px; color: var(--muted);
  min-height: 18px;
  transition: color 0.4s var(--ease), opacity 0.4s var(--ease);
  opacity: 0.95;
}
.status.busy { color: var(--text); opacity: 0.7; }
.status.err { color: #cfcfcf; }

.spinner {
  display: inline-block; width: 13px; height: 13px;
  margin-right: 8px; vertical-align: -2px;
  border: 2px solid rgba(255, 255, 255, 0.22);
  border-top-color: rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.editor.out.fade { animation: fadeIn 0.6s var(--ease) both; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.foot {
  max-width: 1180px; margin: 0 auto;
  padding: 10px 28px 34px;
  display: flex; align-items: center; gap: 10px;
  color: var(--muted); font-size: 12.5px;
  animation: rise 0.9s var(--ease) both;
  animation-delay: 0.26s;
}
.foot .sep { opacity: 0.5; }

@media (max-width: 820px) {
  .stage { grid-template-columns: 1fr; }
  .panel { min-height: 380px; }
  .btn.primary { margin-left: 0; width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .bg, .panel, .top, .foot, .editor.out.fade, .spinner { animation: none !important; }
}
