/* RootTerm: Discord-native. Discord's own greys and blurple, real server icons, no decoration. */
:root {
  --bg: #313338;          /* main surface */
  --bg-2: #2b2d31;        /* sidebar / cards */
  --bg-3: #1e1f22;        /* deepest: inputs, code, rail */
  --hover: #35373c;
  --line: #3f4147;
  --fg: #dbdee1;
  --head: #f2f3f5;
  --muted: #949ba4;
  --faint: #6d6f78;
  --blurple: #5865f2;
  --blurple-hover: #4752c4;
  --green: #23a55a;
  --yellow: #f0b232;
  --red: #f23f43;
  --link: #00a8fc;
  --sans: "Noto Sans", "Helvetica Neue", Helvetica, Arial, system-ui, sans-serif;
  --mono: "IBM Plex Mono", Consolas, "Andale Mono WT", Menlo, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.5 var(--sans); overflow-x: hidden; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--mono); font-size: .875em; background: var(--bg-3); padding: 2px 5px; border-radius: 4px; }
[hidden] { display: none !important; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 24px; }

/* ── buttons (Discord's) ───────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 38px; padding: 2px 16px;
  border: 0; border-radius: 3px; background: #4e5058; color: #fff; font: 500 14px/16px var(--sans); cursor: pointer;
  text-decoration: none !important; white-space: nowrap; transition: background-color .17s ease; }
.btn:hover { background: #6d6f78; }
.btn.blurple { background: var(--blurple); }
.btn.blurple:hover { background: var(--blurple-hover); }
.btn.green { background: var(--green); }
.btn.green:hover { background: #1a8b4c; }
.btn.link { background: none; color: var(--fg); }
.btn.link:hover { text-decoration: underline !important; }
.btn.big { min-height: 44px; padding: 2px 24px; font-size: 16px; }
.btn.sm { min-height: 32px; padding: 2px 14px; font-size: 14px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }

/* ── top bar ───────────────────────────────────────────── */
.topbar { background: var(--bg-3); }
.topbar .wrap { display: flex; align-items: center; gap: 28px; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--head) !important; font-weight: 700; font-size: 18px;
  text-decoration: none !important; }
.brand img, .brand .mark { width: 34px; height: 34px; border-radius: 50%; }
.brand .mark { display: grid; place-items: center; background: var(--blurple); color: #fff; font: 700 13px var(--mono); }
.topbar nav { display: flex; gap: 22px; }
.topbar nav a { color: var(--muted); font-weight: 500; text-decoration: none; }
.topbar nav a:hover, .topbar nav a.on { color: var(--head); }
.topbar .right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.me { display: flex; align-items: center; gap: 8px; color: var(--head); font-weight: 600; font-size: 14px; }
.me img { width: 32px; height: 32px; border-radius: 50%; background: var(--bg-2); }
@media (max-width: 720px) { .topbar nav { display: none; } .topbar .wrap { gap: 12px; } .me span { display: none; } }

/* ── landing ───────────────────────────────────────────── */
.hero { padding: 72px 0 32px; }
.hero .wrap { display: grid; grid-template-columns: 1fr 1fr; gap: 56px; align-items: center; }
.hero h1 { margin: 0 0 16px; color: var(--head); font-size: 44px; line-height: 1.1; font-weight: 800; }
.hero p { margin: 0 0 12px; font-size: 17px; color: var(--fg); max-width: 520px; }
.hero .actions { display: flex; gap: 12px; margin-top: 28px; flex-wrap: wrap; }
.hero .sub { margin-top: 14px; color: var(--muted); font-size: 14px; }
@media (max-width: 900px) { .hero .wrap { grid-template-columns: 1fr; gap: 36px; } .hero h1 { font-size: 34px; } }
.hero .wrap > div, .row > div { min-width: 0; }

.panel { background: var(--bg-2); border-radius: 8px; overflow: hidden; }
.panel .head { display: flex; align-items: center; gap: 8px; height: 48px; padding: 0 16px; border-bottom: 1px solid var(--bg-3);
  color: var(--head); font-weight: 600; box-shadow: 0 1px 0 rgba(4, 4, 5, .2); }
.panel .head .hash { color: var(--faint); font-size: 22px; font-weight: 400; }
.panel .head .topic { color: var(--muted); font-weight: 400; font-size: 14px; border-left: 1px solid var(--line); padding-left: 10px; margin-left: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel pre { margin: 0; padding: 14px 16px 16px; background: var(--bg-3); color: #d1d4d8; font: 13px/1.6 var(--mono);
  overflow-x: auto; white-space: pre; }
.k-p { color: #57d18b; } .k-y { color: #f0b232; } .k-g { color: #57d18b; } .k-d { color: var(--faint); }
.k-key { color: #8ea1ff; } .k-str { color: #f0b232; } .k-com { color: var(--faint); }

.features { padding: 0 0 56px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 56px; align-items: center; padding: 40px 0; }
.row + .row { border-top: 1px solid var(--line); }
.row h2 { margin: 0 0 10px; color: var(--head); font-size: 26px; font-weight: 700; }
.row p { margin: 0 0 10px; color: var(--fg); }
.row ul { margin: 8px 0 0; padding-left: 18px; color: var(--fg); }
.row ul li { margin: 4px 0; }
@media (max-width: 900px) { .row { grid-template-columns: 1fr; gap: 24px; } .row.flip > div:first-child { order: 2; } }

.cta { background: var(--bg-2); }
.cta .wrap { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 40px 24px; flex-wrap: wrap; }
.cta h2 { margin: 0 0 4px; color: var(--head); font-size: 24px; }
.cta p { margin: 0; color: var(--muted); }

footer { background: var(--bg-3); color: var(--muted); font-size: 14px; }
footer .wrap { display: flex; gap: 22px; align-items: center; padding: 28px 24px; flex-wrap: wrap; }
footer a { color: var(--muted); }
footer .brand { font-size: 15px; }
footer .brand .mark, footer .brand img { width: 26px; height: 26px; font-size: 11px; }
footer .spacer { flex: 1; }

/* ── dashboard: server picker ──────────────────────────── */
.page { padding-top: 40px; padding-bottom: 72px; }
.page h1 { margin: 0 0 4px; color: var(--head); font-size: 28px; font-weight: 800; text-align: center; }
.page .lead { margin: 0 0 32px; color: var(--muted); text-align: center; }
.guilds { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 20px; }
.guild { background: var(--bg-2); border-radius: 8px; overflow: hidden; display: flex; flex-direction: column; }
.guild .banner { position: relative; height: 120px; display: grid; place-items: center; overflow: hidden; background: var(--bg-3); }
.guild .banner .blur { position: absolute; inset: -20px; background-size: cover; background-position: center;
  filter: blur(18px) brightness(.6); transform: scale(1.1); }
.guild .icon { position: relative; width: 80px; height: 80px; border-radius: 50%; display: grid; place-items: center;
  background: var(--bg); color: var(--head); font-size: 26px; font-weight: 600; overflow: hidden; border: 3px solid var(--bg-2); }
.guild .icon img { width: 100%; height: 100%; object-fit: cover; }
.guild .body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.guild .name { color: var(--head); font-weight: 700; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.guild .meta { color: var(--muted); font-size: 13px; display: flex; gap: 6px; align-items: center; }
.guild .meta .st::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: var(--yellow); }
.guild .meta .st.ok::before { background: var(--green); }
.guild .meta .st.off::before { background: var(--faint); }
.guild .buttons { display: flex; gap: 8px; margin-top: 12px; }
.guild .buttons .btn { flex: 1; }
.empty { text-align: center; color: var(--muted); padding: 24px 0; }
.toast { min-height: 1.4em; margin: 18px 0 0; text-align: center; font-size: 14px; }
.toast.ok { color: #57d18b; } .toast.err { color: #fa777c; }
.signin { max-width: 440px; margin: 48px auto; padding: 32px; background: var(--bg-2); border-radius: 8px; text-align: center; }
.signin h1 { margin-bottom: 8px; }
.signin p { color: var(--muted); margin: 0 0 22px; }

/* ── modal (Discord style) ─────────────────────────────── */
.modal-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, .85); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { width: 100%; max-width: 440px; background: var(--bg); border-radius: 8px; overflow: hidden; }
.modal .m-body { padding: 24px 16px 8px; }
.modal h2 { margin: 0 0 8px; color: var(--head); font-size: 20px; font-weight: 700; text-align: center; }
.modal p.m-sub { margin: 0 0 16px; color: var(--muted); text-align: center; font-size: 14px; }
.modal label { display: block; margin: 16px 0 8px; color: #b5bac1; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .02em; }
.modal input[type=text], .modal input[type=password] { width: 100%; height: 40px; padding: 0 10px; border: 0; border-radius: 3px;
  background: var(--bg-3); color: var(--head); font: 14px var(--mono); }
.modal input:focus { outline: none; box-shadow: 0 0 0 2px var(--link); }
.modal .check { display: flex; gap: 8px; align-items: center; margin: 16px 0 0; color: var(--fg); font-size: 14px; text-transform: none; letter-spacing: 0; font-weight: 400; }
.modal .check input { width: 18px; height: 18px; accent-color: var(--blurple); }
.modal .err { min-height: 1.3em; margin: 10px 0 0; color: #fa777c; font-size: 14px; }
.modal .m-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 16px; background: var(--bg-2); }

/* ── terminal page ─────────────────────────────────────── */
.term-page { display: flex; height: 100vh; height: 100dvh; background: var(--bg-3); }
.rail { width: 72px; flex: none; background: var(--bg-3); display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 12px 0; }
.rail a { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; background: var(--bg); color: var(--head);
  font-weight: 600; text-decoration: none !important; overflow: hidden; transition: border-radius .15s; }
.rail a:hover, .rail a.on { border-radius: 16px; }
.rail a img { width: 100%; height: 100%; object-fit: cover; }
.rail a.home { background: var(--blurple); font: 700 13px var(--mono); color: #fff; }
.rail .sep { width: 32px; height: 2px; border-radius: 1px; background: var(--line); }
.term-main { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg); }
.term-head { display: flex; align-items: center; gap: 8px; height: 48px; padding: 0 16px; flex: none; color: var(--head); font-weight: 600;
  box-shadow: 0 1px 0 rgba(4, 4, 5, .2), 0 1.5px 0 rgba(6, 6, 7, .05), 0 2px 0 rgba(4, 4, 5, .05); }
.term-head .hash { color: var(--faint); font-size: 22px; font-weight: 400; }
.term-head .topic { color: var(--muted); font-weight: 400; font-size: 14px; border-left: 1px solid var(--line); padding-left: 10px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.term-head .right { margin-left: auto; display: flex; align-items: center; gap: 14px; color: var(--muted); font-weight: 400; font-size: 13px; }
.conn::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: var(--yellow); }
.conn[data-state="connected"]::before { background: var(--green); }
.conn[data-state="disconnected"]::before { background: var(--red); }
#terminal { flex: 1; min-height: 0; margin: 0 16px 16px; padding: 10px 0 0 12px; border-radius: 8px; background: var(--bg-3); }
@media (max-width: 600px) { .rail { display: none; } #terminal { margin: 0; border-radius: 0; } .term-head .topic, .term-head .hide-sm { display: none; } }

.editor { position: fixed; inset: 0; background: var(--bg); display: none; flex-direction: column; z-index: 30; }
.editor.open { display: flex; }
.editor header { display: flex; align-items: center; gap: 10px; height: 48px; padding: 0 16px; color: var(--head);
  box-shadow: 0 1px 0 rgba(4, 4, 5, .2); }
.editor header .path { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 14px var(--mono); }
.editor .status { color: var(--muted); font-size: 13px; }
.editor .status.bad { color: #fa777c; }
.editor .CodeMirror { flex: 1; height: auto; margin: 0 16px 16px; border-radius: 8px; font-family: var(--mono); font-size: 14px; background: var(--bg-3); color: var(--fg); }
.editor .CodeMirror-gutters { background: var(--bg-3); border-right: 1px solid var(--bg-2); }
.editor .CodeMirror-linenumber { color: var(--faint); }
.editor .CodeMirror-cursor { border-left: 2px solid var(--head); }
.editor .CodeMirror-selected, .editor .CodeMirror-focused .CodeMirror-selected { background: rgba(88, 101, 242, .3); }
.cm-keyword { color: #8ea1ff; } .cm-string { color: #f0b232; } .cm-comment { color: var(--faint); }
.cm-number, .cm-atom { color: #57d18b; } .cm-def { color: var(--head); font-weight: 600; } .cm-builtin { color: #00a8fc; }
.cm-variable { color: var(--fg); }
.diag-error { text-decoration: underline wavy var(--red); text-underline-offset: 3px; }
.diag-warning { text-decoration: underline wavy var(--yellow); text-underline-offset: 3px; }
.diags { max-height: 30vh; overflow: auto; margin: -8px 16px 16px; border-radius: 8px; background: var(--bg-2); font: 13px var(--mono); }
.diags div { padding: 8px 12px; cursor: pointer; border-bottom: 1px solid var(--bg); }
.diags div:hover { background: var(--hover); }
.diags .sev-error { color: #fa777c; } .diags .sev-warning { color: var(--yellow); }
.diags .hint { display: block; color: var(--muted); padding-left: 6ch; }

/* ── phone key bar (Esc, Ctrl, arrows, editor shortcuts) ─ */
.keybar { display: none; gap: 6px; padding: 6px 8px; overflow-x: auto; background: var(--bg-2); flex: none;
  scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.keybar::-webkit-scrollbar { display: none; }
.keybar button { flex: none; min-width: 44px; height: 36px; padding: 0 10px; border: 0; border-radius: 6px;
  background: var(--bg-3); color: var(--head); font: 500 14px var(--mono); touch-action: manipulation; }
.keybar button:active, .keybar button.on { background: var(--blurple); color: #fff; }
.keybar .for-nano, .keybar .for-vim { display: none; }
.keybar[data-mode="nano"] .for-nano, .keybar[data-mode="vim"] .for-vim { display: inline-block; }
.keybar[data-mode="nano"] .for-shell, .keybar[data-mode="vim"] .for-shell { display: none; }
@media (pointer: coarse), (max-width: 700px) { .keybar { display: flex; } #terminal { margin-bottom: 8px; } }
.rail a.home.has-img { background: none; }

/* ── credits and plans ─────────────────────────────────── */
.wallet { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  margin: 0 0 24px; padding: 14px 16px; background: var(--bg-2); border-radius: 8px; }
.wallet .balance { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.wallet .label { color: var(--muted); font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .02em; }
.wallet strong { color: var(--head); font-size: 22px; }
.wallet .hint { color: var(--muted); font-size: 13px; }
.wallet .packs { display: flex; gap: 8px; flex-wrap: wrap; }
.guild .meta .plan { margin-left: auto; padding: 1px 8px; border-radius: 4px; font-size: 12px; font-weight: 600;
  background: var(--bg-3); color: var(--muted); }
.guild .meta .plan.premium { background: rgba(35, 165, 90, .15); color: #57d18b; }
.guild .buttons + .buttons, .guild .buttons > div + div { margin-top: 8px; }

/* ── custom bot modal ──────────────────────────────────── */
.cb-current { display: flex; align-items: center; gap: 12px; margin: 4px 0 8px; padding: 12px; border-radius: 8px; background: var(--bg-2); }
.cb-current img { width: 48px; height: 48px; border-radius: 50%; }
.cb-current strong { color: var(--head); }
.cb-state { font-size: 13px; color: var(--muted); }
.cb-state.ok { color: #57d18b; } .cb-state.warn { color: var(--yellow); }
.cb-steps { margin: 0 0 4px; padding-left: 20px; color: var(--fg); font-size: 14px; }
.cb-steps li { margin: 6px 0; }
.ok-msg { min-height: 1.3em; margin: 8px 0 0; color: #57d18b; font-size: 14px; }
.modal .m-foot { align-items: center; }
