:root {
  --bg: #000;
  --panel: rgba(8, 8, 8, 0.82);
  --panel-solid: #080808;
  --line: rgba(255, 255, 255, 0.16);
  --line-strong: rgba(255, 255, 255, 0.42);
  --text: #f4f4f4;
  --dim: rgba(255, 255, 255, 0.55);
  --faint: rgba(255, 255, 255, 0.32);
  --up: #d9ffd9;
  --down: #ffd6d6;
  --glow: 0 0 18px rgba(255, 255, 255, 0.18);
  --mono: "JetBrains Mono", "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --radius: 4px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--text); }
::selection { background: #fff; color: #000; }

#stars { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }
.scan {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background: repeating-linear-gradient(to bottom, rgba(255,255,255,0.025) 0 1px, transparent 1px 3px);
  mix-blend-mode: overlay;
}
.app { position: relative; z-index: 2; max-width: 1180px; margin: 0 auto; padding: 0 16px 80px; }

/* ---------- header (same bar as X09 Hub) */
@font-face { font-family: "JetBrains Mono"; src: url("/x09/jetbrains-mono.woff") format("woff"); font-weight: 100 800; font-display: swap; }
.navpill {
  position: sticky; top: 12px; z-index: 50; margin: 12px 0 0; display: flex; align-items: center; gap: 12px;
  height: 60px; padding: 0 10px 0 18px; background: #000; border: 1px solid rgba(255,255,255,0.32);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.x09-logo { display: grid; place-items: center; width: 32px; height: 32px; cursor: pointer; }
.x09-wordmark { display: inline-flex; align-items: baseline; gap: .45em; font: 800 16px var(--mono); letter-spacing: -.02em; white-space: nowrap; }
.x09-wordmark small { font: 500 .95rem var(--mono); color: #a3a3a3; letter-spacing: 0; }
.x09-wordmark small::before { content: "\\"; margin-right: .05em; }
.x09-wordmark::after { content: ""; display: inline-block; width: .5em; height: .95em; margin-left: .12em; vertical-align: -.12em; background: #fff; animation: x09blink 1.05s steps(1) infinite; }
@keyframes x09blink { 50% { opacity: 0; } }

nav.tabs { display: flex; gap: 2px; margin-left: 14px; }
nav.tabs button {
  background: none; border: 0; padding: 8px 14px; cursor: pointer; color: #a3a3a3;
  font: 700 .76rem var(--mono); letter-spacing: .08em; text-transform: uppercase; transition: background .2s, color .2s;
}
nav.tabs button:hover { background: #fff; color: #000; }
nav.tabs button[aria-selected="true"] { background: #fff; color: #000; }
nav.tabs-mobile { display: none; }

.x09-switch { position: relative; }
.x09-switch-btn {
  width: 38px; height: 38px; display: grid; place-items: center; padding: 0; cursor: pointer; color: var(--text);
  border: 1px solid rgba(255,255,255,0.32); background: rgba(255,255,255,0.05); transition: border-color .2s, background .2s;
}
.x09-switch-btn:hover, .x09-switch-btn[aria-expanded="true"] { border-color: rgba(255,255,255,.6); background: rgba(255,255,255,.14); }
.x09-switch-menu {
  position: absolute; right: 0; top: calc(100% + 12px); z-index: 70; width: 330px; padding: 8px;
  background: #000; border: 1px solid #fff; box-shadow: 0 0 0 4px #000, 0 0 0 5px rgba(255,255,255,.08);
}
.x09-switch-head { padding: 8px 10px 10px; font-size: .8rem; color: #9a9a9a; }
.x09-switch-item { display: flex; align-items: center; gap: 12px; padding: 10px; color: var(--text); text-decoration: none; transition: background .15s; }
.x09-switch-item:hover { background: rgba(255,255,255,.06); }
.x09-switch-item.here { background: #111; outline: 1px solid rgba(255,255,255,.14); }
.x09-switch-orb { width: 38px; height: 38px; flex-shrink: 0; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.45); }
.x09-switch-item b { display: block; font-weight: 700; font-size: .92rem; }
.x09-switch-item div span { display: block; font-size: .76rem; color: #9a9a9a; }
.x09-chip { margin-left: auto; font-size: .66rem; letter-spacing: .08em; text-transform: uppercase; padding: 3px 8px; border: 1px solid #fff; }
.x09-chip.on { background: #fff; color: #000; }

.account-btn {
  height: 38px; padding: 0 18px; cursor: pointer; background: #000; color: #fff;
  border: 1px solid rgba(255,255,255,0.32); font: 700 .82rem var(--mono); letter-spacing: .08em; text-transform: uppercase;
  white-space: nowrap; display: inline-flex; align-items: center; gap: 8px; transition: background .15s, color .15s, border-color .15s;
}
.account-btn:hover { background: #fff; color: #000; border-color: #fff; }
.account-btn.connected { background: #fff; color: #000; border-color: #fff; }
.account-btn.connected .dot { background: #000; box-shadow: none; }
.spacer { flex: 1; }

.btn {
  border: 1px solid var(--line-strong); background: transparent; color: var(--text);
  padding: 8px 14px; cursor: pointer; border-radius: var(--radius); letter-spacing: 0.06em;
  transition: background .15s, color .15s, box-shadow .15s, transform .1s;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { background: #fff; color: #000; box-shadow: var(--glow); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.solid { background: #fff; color: #000; }
.btn.solid:hover:not(:disabled) { background: #ddd; }
.btn.big { width: 100%; padding: 14px; font-size: 15px; font-weight: 600; letter-spacing: 0.14em; }
.btn.small { padding: 4px 8px; font-size: 12px; }
.btn.ghost { border-color: var(--line); color: var(--dim); }

.chainpick { position: relative; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line);
  border-radius: 999px; padding: 5px 11px; background: rgba(255,255,255,0.03); cursor: pointer;
  color: var(--text); font-size: 12px; letter-spacing: 0.05em;
}
.chip:hover { border-color: var(--line-strong); }
.chip[aria-pressed="true"] { background: #fff; color: #000; border-color: #fff; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: #fff; box-shadow: 0 0 6px #fff; }
.dot.off { background: transparent; border: 1px solid var(--dim); box-shadow: none; }

/* ---------- layout */
main { padding-top: 22px; }
.view { display: none; }
.view.on { display: block; animation: rise .25s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.prompt { color: var(--dim); font-size: 12px; letter-spacing: 0.12em; margin: 0 0 10px; }
.prompt::before { content: "> "; color: var(--text); }
.cursor::after { content: "_"; animation: blink 1s steps(1) infinite; margin-left: 2px; }
@keyframes blink { 50% { opacity: 0; } }

.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.03), 0 20px 60px rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
}
.panel-head {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--line);
  font-size: 11px; color: var(--dim); letter-spacing: 0.14em;
}
.lights { display: flex; gap: 5px; }
.lights i { width: 8px; height: 8px; border-radius: 50%; border: 1px solid var(--line-strong); }
.lights i:first-child { background: #fff; }
.panel-body { padding: 16px; }

/* ---------- swap */
.swap-wrap { display: grid; grid-template-columns: minmax(0, 460px) minmax(0, 1fr); gap: 22px; align-items: start; }
.chainrow { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }

.leg { border: 1px solid var(--line); border-radius: 6px; padding: 12px; background: rgba(255,255,255,0.02); }
.leg:focus-within { border-color: var(--line-strong); }
.leg-top { display: flex; justify-content: space-between; font-size: 11px; color: var(--dim); letter-spacing: 0.12em; margin-bottom: 8px; }
.leg-top button { background: none; border: none; color: var(--dim); cursor: pointer; padding: 0; font-size: 11px; }
.leg-top button:hover { color: var(--text); text-decoration: underline; }
.leg-row { display: flex; align-items: center; gap: 10px; }
.amount {
  flex: 1; min-width: 0; width: 100%; background: none; border: none; outline: none; font-size: 26px; font-weight: 600;
  padding: 2px 0; letter-spacing: 0.02em;
}
.amount::placeholder { color: var(--faint); }
.amount[readonly] { cursor: default; }
.usd { font-size: 11px; color: var(--dim); margin-top: 4px; min-height: 16px; }
.tokbtn {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px 6px 6px; border: 1px solid var(--line-strong);
  background: #000; border-radius: 999px; cursor: pointer; font-weight: 600; flex-shrink: 0; max-width: 60%;
}
.tokbtn:hover { background: #fff; color: #000; }
.tokbtn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tokimg {
  width: 24px; height: 24px; border-radius: 50%; object-fit: cover; flex-shrink: 0;
  background: #111; border: 1px solid var(--line); display: inline-grid; place-items: center; font-size: 10px; color: var(--text);
}
.flip-row { display: flex; justify-content: center; margin: -8px 0; position: relative; z-index: 2; }
.flip {
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line-strong); background: #000;
  cursor: pointer; display: grid; place-items: center; transition: transform .25s;
}
.flip:hover { transform: rotate(180deg); background: #fff; color: #000; }

.details { margin: 12px 0; font-size: 12px; border-top: 1px dashed var(--line); padding-top: 10px; }
.details div { display: flex; justify-content: space-between; gap: 10px; padding: 2px 0; color: var(--dim); }
.details div b { color: var(--text); font-weight: 500; text-align: right; }
.warn { color: var(--down) !important; }

.settings { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 11px; color: var(--dim); margin-bottom: 12px; }
.settings .chip { padding: 3px 9px; }
.settings input { width: 60px; background: none; border: 1px solid var(--line); border-radius: 999px; padding: 3px 8px; text-align: center; }

.side-card { padding: 16px; }
.term { font-size: 12px; color: var(--dim); white-space: pre-wrap; }
.term .ok { color: var(--text); }
.term .err { color: var(--down); }
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 12px; }
.stat { border: 1px solid var(--line); border-radius: 6px; padding: 10px; }
.stat small { display: block; color: var(--dim); font-size: 10px; letter-spacing: 0.14em; }
.stat b { font-size: 18px; }

/* ---------- explore */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.search {
  flex: 1; min-width: 200px; background: rgba(255,255,255,0.03); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 9px 12px; outline: none;
}
.search:focus { border-color: var(--line-strong); }
table.market { width: 100%; border-collapse: collapse; font-size: 13px; }
table.market th { text-align: right; font-weight: 400; color: var(--dim); font-size: 10px; letter-spacing: 0.14em; padding: 8px; border-bottom: 1px solid var(--line); }
table.market th:first-child, table.market td:first-child { text-align: left; }
table.market td { text-align: right; padding: 10px 8px; border-bottom: 1px dashed var(--line); white-space: nowrap; }
table.market tbody tr { cursor: pointer; transition: background .12s; }
table.market tbody tr:hover { background: rgba(255,255,255,0.06); }
.tokcell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.tokcell b { display: block; }
.tokcell small { color: var(--dim); display: block; max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.up { color: var(--up); }
.down { color: var(--down); }
.up::before { content: "▲ "; font-size: 9px; }
.down::before { content: "▼ "; font-size: 9px; }
.empty { padding: 40px 16px; text-align: center; color: var(--dim); }
.hide-sm {}

/* ---------- launch */
.launch-wrap { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 380px); gap: 22px; align-items: start; }
.form { display: grid; gap: 14px; }
.field label { display: block; font-size: 11px; color: var(--dim); letter-spacing: 0.12em; margin-bottom: 6px; }
.field input[type=text], .field input[type=number], .field input[type=url], .field textarea, .field select {
  width: 100%; background: rgba(255,255,255,0.03); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 12px; outline: none;
}
.field textarea { min-height: 70px; resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--line-strong); }
.field .hint { font-size: 11px; color: var(--faint); margin-top: 4px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.logo-drop {
  display: flex; align-items: center; gap: 14px; border: 1px dashed var(--line-strong); border-radius: 6px; padding: 12px; cursor: pointer;
}
.logo-drop:hover { background: rgba(255,255,255,0.04); }
.logo-drop .preview { width: 64px; height: 64px; border-radius: 50%; border: 1px solid var(--line); background: #0c0c0c center/cover; display: grid; place-items: center; color: var(--faint); font-size: 22px; flex-shrink: 0; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; cursor: pointer; }
.check input { margin-top: 3px; accent-color: #fff; }
.check small { display: block; color: var(--dim); font-size: 11px; }
fieldset { border: 1px solid var(--line); border-radius: 6px; padding: 12px 14px 14px; margin: 0; display: grid; gap: 12px; }
legend { padding: 0 6px; font-size: 11px; color: var(--dim); letter-spacing: 0.14em; }
.launch-log { min-height: 120px; max-height: 320px; overflow: auto; background: #000; border: 1px solid var(--line); border-radius: 6px; padding: 10px; }
.result { border: 1px solid #fff; border-radius: 6px; padding: 12px; margin-top: 12px; box-shadow: var(--glow); }
.result code { word-break: break-all; }
.launches { display: grid; gap: 8px; }
.launch-item { display: flex; align-items: center; gap: 10px; padding: 8px; border: 1px solid var(--line); border-radius: 6px; cursor: pointer; }
.launch-item:hover { border-color: var(--line-strong); background: rgba(255,255,255,0.04); }
.launch-item small { color: var(--dim); display: block; }

/* ---------- modal */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,0.72); display: none; align-items: flex-start; justify-content: center; padding: 8vh 16px 16px; }
.modal.on { display: flex; animation: rise .18s ease-out; }
.modal .panel { width: 100%; max-width: 440px; max-height: 80vh; display: flex; flex-direction: column; background: var(--panel-solid); }
.modal .panel-body { overflow: auto; }
.tok-list { display: grid; gap: 2px; margin-top: 10px; }
.tok-item { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 6px; cursor: pointer; border: 1px solid transparent; background: none; text-align: left; width: 100%; }
.tok-item:hover { border-color: var(--line); background: rgba(255,255,255,0.05); }
.tok-item small { display: block; color: var(--dim); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 300px; }
.wallet-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px; border: 1px solid var(--line); border-radius: 6px; background: none; cursor: pointer; margin-bottom: 8px; text-align: left; }
.wallet-item:hover { border-color: #fff; background: rgba(255,255,255,0.05); }
.wallet-item img { width: 28px; height: 28px; border-radius: 6px; }
.xbtn { margin-left: auto; background: none; border: none; color: var(--dim); cursor: pointer; font-size: 16px; }
.xbtn:hover { color: var(--text); }

.toast-wrap { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 60; display: grid; gap: 8px; width: min(92vw, 440px); }
.toast { background: #000; border: 1px solid #fff; padding: 10px 14px; border-radius: 6px; font-size: 13px; box-shadow: var(--glow); animation: rise .2s ease-out; word-break: break-word; }
.toast.err { border-color: var(--down); color: var(--down); }

footer { margin-top: 40px; font-size: 11px; color: var(--faint); border-top: 1px dashed var(--line); padding-top: 14px; display: flex; flex-wrap: wrap; gap: 14px; justify-content: space-between; }
footer a { color: var(--dim); }

.spin { display: inline-block; width: 12px; height: 12px; border: 1.5px solid var(--dim); border-top-color: #fff; border-radius: 50%; animation: rot .7s linear infinite; vertical-align: -2px; }
@keyframes rot { to { transform: rotate(360deg); } }

/* ---------- responsive */
@media (max-width: 900px) {
  .swap-wrap, .launch-wrap { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 680px) {
  .navpill { height: 54px; padding: 0 6px 0 14px; gap: 8px; top: 10px; margin-top: 10px; }
  nav.tabs { display: none; }
  nav.tabs-mobile { display: flex; margin: 10px 0 0; border: 1px solid rgba(255,255,255,0.32); background: #000; }
  nav.tabs-mobile button { flex: 1; }
  .x09-switch-menu { position: fixed; top: 70px; right: 10px; width: min(330px, calc(100vw - 20px)); }
  .hide-sm { display: none; }
  .row2, .row3 { grid-template-columns: 1fr; }
  .amount { font-size: 22px; }
  table.market td, table.market th { padding: 8px 5px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

[hidden] { display: none !important; }
.hint { font-size: 11px; color: var(--faint); }
