/* ============ Reset & variables ============ */
*, *::before, *::after { box-sizing: border-box; }

:root {
  --bg: #06070b;
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.18);
  --text: #e8eaf2;
  --muted: #8a91a8;
  --accent: #6366f1;
  --accent-2: #22d3ee;
  --green: #34d399;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 20px;
  font-family: var(--sans);
  color: var(--text);
  background:
    radial-gradient(1100px 600px at 12% -8%, rgba(99, 102, 241, 0.20), transparent 60%),
    radial-gradient(900px 500px at 92% 4%, rgba(34, 211, 238, 0.12), transparent 55%),
    radial-gradient(900px 700px at 50% 115%, rgba(139, 92, 246, 0.12), transparent 60%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
}
body::before {
  content: "";
  position: fixed; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px);
  background-size: 60px 60px;
  -webkit-mask-image: radial-gradient(ellipse at 50% 30%, #000 20%, transparent 75%);
          mask-image: radial-gradient(ellipse at 50% 30%, #000 20%, transparent 75%);
  pointer-events: none; z-index: 0;
}

/* ============ Layout ============ */
.wrap { position: relative; z-index: 1; width: 100%; max-width: 1180px; }

.hero { text-align: center; margin-bottom: 28px; animation: fadeUp .6s ease both; }

h1 {
  margin: 0;
  font-size: clamp(32px, 5vw, 46px);
  line-height: 1.1;
  letter-spacing: -0.025em;
  font-weight: 700;
}
.grad {
  background: linear-gradient(90deg, #818cf8, #22d3ee 60%, #a78bfa);
  -webkit-background-clip: text;
          background-clip: text;
  color: transparent;
}

/* ============ Mode switch ============ */
.mode-switch {
  display: flex; gap: 6px;
  margin: 0 auto 22px;
  padding: 5px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: fit-content;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: fadeUp .6s .05s ease both;
}
.mode-switch button {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 22px;
  border: none; border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 13.5px; font-weight: 600;
  cursor: pointer;
  transition: all .18s ease;
}
.mode-switch button:hover { color: var(--text); }
.mode-switch button.active {
  background: linear-gradient(180deg, rgba(99,102,241,.45), rgba(99,102,241,.22));
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.15), 0 3px 10px rgba(99,102,241,.35);
}
.mode-switch button svg { width: 15px; height: 15px; }

/* ============ Page grid ============ */
.page-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
  align-items: start;
  animation: fadeUp .7s .1s ease both;
}
@media (max-width: 1024px) { .page-grid { grid-template-columns: 1fr; } }

/* ============ Card base ============ */
.card {
  position: relative;
  padding: 22px;
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(255,255,255,.055), rgba(255,255,255,.02));
  border: 1px solid var(--border);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 40px 90px -30px rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(24px) saturate(140%);
  -webkit-backdrop-filter: blur(24px) saturate(140%);
}
.card::before {
  content: "";
  position: absolute; inset: 0; border-radius: inherit; padding: 1px;
  background: linear-gradient(180deg, rgba(255,255,255,.18), transparent 40%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
          mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  pointer-events: none;
}

/* ============ Main card layout ============ */
.layout {
  display: grid;
  grid-template-columns: 230px 1fr;
  grid-template-areas: "side main";
  gap: 18px;
}
.side-col { grid-area: side; min-width: 0; }
.main-col { grid-area: main; min-width: 0; }
@media (max-width: 640px) {
  .layout { grid-template-columns: 1fr; grid-template-areas: "side" "main"; }
}

/* ============ Search ============ */
.search {
  width: 100%; height: 42px;
  padding: 0 14px 0 38px;
  border-radius: 11px;
  background-color: rgba(0, 0, 0, 0.35);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238a91a8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 13px center;
  background-size: 15px;
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--sans); font-size: 13.5px;
  transition: border-color .18s, box-shadow .18s, background-color .18s;
}
.search::placeholder { color: var(--muted); }
.search:hover { border-color: var(--border-strong); }
.search:focus {
  outline: none;
  border-color: rgba(99, 102, 241, 0.65);
  background-color: rgba(0, 0, 0, 0.5);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.14);
}

/* ============ OS tabs ============ */
.os-tabs { display: flex; gap: 5px; margin: 10px 0 12px; flex-wrap: wrap; }
.os-tabs button {
  flex: 1; min-width: 55px; height: 32px;
  padding: 0 8px;
  font-family: var(--sans); font-size: 11px; font-weight: 600;
  letter-spacing: .02em;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.3);
  color: var(--muted);
  cursor: pointer;
  transition: all .15s ease;
}
.os-tabs button:hover { color: var(--text); border-color: var(--border-strong); }
.os-tabs button.active {
  color: #c7d2fe;
  background: rgba(99, 102, 241, 0.20);
  border-color: rgba(99, 102, 241, 0.5);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08);
}

/* ============ Payload list ============ */
.shell-list {
  list-style: none;
  margin: 0; padding: 0 4px 0 0;
  display: flex; flex-direction: column; gap: 6px;
  max-height: 340px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.15) transparent;
}
.shell-list::-webkit-scrollbar { width: 6px; }
.shell-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 3px; }
.shell-list::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.25); }

.shell-btn {
  width: 100%;
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font-family: var(--sans); font-size: 13px;
  cursor: pointer; text-align: left;
  transition: all .15s ease;
}
.shell-btn:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: var(--border-strong);
  transform: translateX(2px);
}
.shell-name {
  font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.shell-os {
  flex-shrink: 0;
  font-size: 9px; font-weight: 700;
  letter-spacing: .05em; text-transform: uppercase;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.05);
  padding: 3px 6px; border-radius: 5px;
}
.shell-item.active .shell-btn {
  background: linear-gradient(90deg, rgba(99,102,241,.24), rgba(34,211,238,.10));
  border-color: rgba(99, 102, 241, 0.55);
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06);
}
.shell-item.active .shell-os {
  color: #c7d2fe;
  background: rgba(99, 102, 241, 0.25);
}
.empty-state {
  display: none;
  padding: 16px 12px;
  text-align: center;
  font-size: 12.5px;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: 10px;
  margin-top: 6px;
}

/* ============ Fields ============ */
.fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 18px;
}
.field { display: flex; flex-direction: column; gap: 8px; }
.field > span {
  font-size: 11px; font-weight: 600;
  letter-spacing: .07em; text-transform: uppercase;
  color: var(--muted);
}
.field input, .field select {
  width: 100%; height: 46px;
  padding: 0 14px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--mono); font-size: 14px;
  transition: border-color .18s, box-shadow .18s, background .18s;
}
.field input:hover, .field select:hover { border-color: var(--border-strong); }
.field input:focus, .field select:focus {
  outline: none;
  border-color: rgba(99, 102, 241, 0.65);
  background: rgba(0, 0, 0, 0.5);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.14);
}

/* ============ Options row (Shell + Encoding) ============ */
.options-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 16px;
}
.option-select {
  width: 100%; height: 46px;
  padding: 0 38px 0 14px;
  border-radius: 12px;
  background-color: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--sans); font-size: 13.5px;
  cursor: pointer;
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238a91a8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
  transition: border-color .18s, box-shadow .18s, background-color .18s;
}
.option-select:hover:not(:disabled) { border-color: var(--border-strong); }
.option-select:focus { outline: none; border-color: rgba(99, 102, 241, 0.65);
  background-color: rgba(0, 0, 0, 0.5); box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.14); }
.option-select option { background: #0d0f16; color: var(--text); }
.option-select:disabled { opacity: .4; cursor: not-allowed; }
.field.disabled > span { opacity: .5; }

/* ============ Listener card ============ */
.listener-card { display: flex; flex-direction: column; gap: 16px; }
.listener-head h2 {
  margin: 0 0 4px;
  font-size: 17px; letter-spacing: -0.01em; font-weight: 700;
}
.listener-head p { margin: 0; font-size: 12.5px; color: var(--muted); }

.listener-select {
  width: 100%; height: 46px;
  padding: 0 38px 0 14px;
  border-radius: 12px;
  background-color: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--sans); font-size: 13.5px;
  cursor: pointer;
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238a91a8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
  transition: border-color .18s, box-shadow .18s, background-color .18s;
}
.listener-select:hover { border-color: var(--border-strong); }
.listener-select:focus {
  outline: none;
  border-color: rgba(99, 102, 241, 0.65);
  background-color: rgba(0, 0, 0, 0.5);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.14);
}
.listener-select option { background: #0d0f16; color: var(--text); }

/* ============ Terminal ============ */
.terminal {
  border-radius: 16px;
  border: 1px solid var(--border);
  background: #0a0b11;
  overflow: hidden;
  box-shadow: 0 20px 50px -25px rgba(0, 0, 0, 0.9);
}
.terminal-head {
  display: flex; align-items: center; gap: 14px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,.01));
}
.dots { display: flex; gap: 7px; flex-shrink: 0; }
.dots span { width: 11px; height: 11px; border-radius: 50%; display: block; }
.dots span:nth-child(1) { background: #ff5f57; }
.dots span:nth-child(2) { background: #febc2e; }
.dots span:nth-child(3) { background: #28c840; }
.terminal-title {
  font-size: 11px; font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 55%;
}
.terminal-actions {
  margin-left: auto;
  display: flex; align-items: center; gap: 8px; flex-shrink: 0;
}

.copy {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px;
  border-radius: 9px;
  font-family: var(--sans);
  font-size: 12.5px; font-weight: 600;
  cursor: pointer;
  color: #c7d2fe;
  background: rgba(99, 102, 241, 0.14);
  border: 1px solid rgba(99, 102, 241, 0.35);
  transition: all .18s ease;
}
.copy:hover {
  background: rgba(99, 102, 241, 0.24);
  border-color: rgba(99, 102, 241, 0.55);
  transform: translateY(-1px);
}
.copy:active { transform: translateY(0); }
.copy.copied {
  color: #bbf7d0;
  background: rgba(52, 211, 153, 0.14);
  border-color: rgba(52, 211, 153, 0.45);
}
.copy svg { width: 15px; height: 15px; }

.cmd {
  margin: 0;
  padding: 18px;
  min-height: 92px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.6;
  color: #d7dcf0;
  white-space: pre-wrap;
  word-break: break-all;
}
.cmd::before { content: "$ "; color: var(--green); }
.cmd::selection { background: rgba(99, 102, 241, 0.35); }
.cmd.flash { animation: flash .35s ease; }
@keyframes flash { from { color: #a5b4fc; } to { color: #d7dcf0; } }

/* ============ Footer + GitHub ============ */
.foot {
  margin-top: 28px;
  display: flex; flex-direction: column; align-items: center; gap: 16px;
}
.foot-text {
  font-size: 12.5px; color: var(--muted); opacity: .8; text-align: center;
}
.github-link {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 9px 18px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  text-decoration: none;
  font-family: var(--sans);
  font-size: 13px; font-weight: 600;
  transition: all .2s ease;
}
.github-link:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: rgba(255, 255, 255, 0.08);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px -8px rgba(255, 255, 255, 0.15);
}
.github-link svg { width: 18px; height: 18px; }

/* ============ Responsive ============ */
@media (max-width: 480px) {
  .terminal-title { max-width: 40%; }
  .copy span { display: none; }
  .copy { padding: 7px 10px; }
  .options-row { grid-template-columns: 1fr; }
}

/* ============ Animations ============ */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}