:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel2: #1d212a;
  --line: #262b36;
  --text: #e6e9ef;
  --dim: #8b94a7;
  --accent: #5b9dff;
  --ok: #3fca7a;
  --warn: #e8b247;
  --err: #f0616d;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, Segoe UI, sans-serif;
  display: flex;
  flex-direction: column;
}

header {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.brand { display: flex; align-items: center; gap: 9px; }
.brand h1 { font-size: 15px; font-weight: 600; margin: 0; letter-spacing: .2px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); transition: background .2s; }
.dot.live { background: var(--ok); box-shadow: 0 0 0 3px rgba(63,202,122,.15); }
.dot.dead { background: var(--err); }
.target { color: var(--dim); font-family: var(--mono); font-size: 12.5px; }
.clock { margin-left: auto; color: var(--dim); font-family: var(--mono); font-size: 12.5px; }

.stats { display: flex; gap: 1px; background: var(--line); border-bottom: 1px solid var(--line); }
.stat { flex: 1; background: var(--panel); padding: 10px 16px; }
.stat .k { color: var(--dim); font-size: 11px; text-transform: uppercase; letter-spacing: .6px; }
.stat .v { font-size: 19px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: 12px; color: var(--dim); font-weight: 400; }

.tabs { display: flex; gap: 2px; padding: 10px 20px 0; background: var(--bg); }
.tab {
  background: none; border: 0; border-bottom: 2px solid transparent;
  color: var(--dim); padding: 8px 14px; font-size: 13px; cursor: pointer; border-radius: 6px 6px 0 0;
}
.tab:hover { color: var(--text); background: var(--panel); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.tab[hidden] { display: none; }

/* One tab per fleet: the main fleet plus each legion. Visually divorced from the
   pane tabs below it because it switches which fleet everything refers to, not
   which view of the same fleet is shown. */
.tabs.scopes { padding-top: 8px; gap: 6px; flex-wrap: wrap; }

/* The legion badge in the global Activity feed. Activity spans fleets, and a bot
   in one legion is not the bot of the same name in another. */
.scope-tag {
  display: inline-block; margin-right: 6px; padding: 0 6px;
  border: 1px solid var(--line); border-radius: 999px;
  font-size: 10px; color: var(--dim); text-transform: uppercase; letter-spacing: .04em;
}
.tab.scope {
  border: 1px solid var(--line); border-radius: 999px;
  padding: 4px 12px; font-size: 12px;
}
.tab.scope.active { border-color: var(--accent); color: var(--text); background: var(--panel); }
.tab.scope:not(.active) { color: var(--dim); }

main { flex: 1; min-height: 0; padding: 16px 20px 24px; }
.pane { display: none; height: 100%; }
.pane.active { display: flex; flex-direction: column; min-height: 0; }

.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.toolbar input { max-width: 260px; }
.hint { color: var(--dim); font-size: 12.5px; }

.tablewrap { flex: 1; min-height: 0; overflow: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  position: sticky; top: 0; z-index: 1;
  text-align: left; padding: 9px 12px; background: var(--panel2);
  color: var(--dim); font-weight: 500; font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px;
  border-bottom: 1px solid var(--line);
}
tbody td { padding: 7px 12px; border-bottom: 1px solid rgba(38,43,54,.55); }
tbody tr:hover { background: rgba(91,157,255,.05); }
td.name { font-family: var(--mono); font-size: 12.5px; }
td.pos, td.items, td.following { font-family: var(--mono); font-size: 12px; color: var(--dim); }

.pill {
  display: inline-block; padding: 1px 7px; border-radius: 999px;
  font-size: 11px; font-weight: 500; letter-spacing: .2px;
  background: rgba(139,148,167,.14); color: var(--dim);
}
.pill.ready { background: rgba(63,202,122,.14); color: var(--ok); }
.pill.authenticating { background: rgba(232,178,71,.14); color: var(--warn); }
.pill.connecting { background: rgba(91,157,255,.14); color: var(--accent); }
.pill.ended { background: rgba(240,97,109,.14); color: var(--err); }
.pill.queued { background: rgba(139,148,167,.1); color: var(--dim); font-style: italic; }

button.mini {
  background: none; border: 1px solid var(--line); color: var(--dim);
  border-radius: 6px; padding: 2px 8px; font-size: 11.5px; cursor: pointer;
}
button.mini:hover { color: var(--err); border-color: var(--err); }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; overflow: auto; align-content: start; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin: 0; }
.card h2 { margin: 0 0 3px; font-size: 13.5px; font-weight: 600; }
.card .sub { margin: 0 0 11px; color: var(--dim); font-size: 12px; }

/* The server card spans the full row: it is the thing to look at first, and it
   carries a list of known servers that would be cramped in a narrow column. */
.card.wide { grid-column: 1 / -1; }

.check { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--dim); cursor: pointer; }
.check input { accent-color: var(--accent); margin: 0; }

.servers { list-style: none; display: flex; flex-wrap: wrap; gap: 7px; padding: 0; margin: 10px 0 0; }
.servers:empty { display: none; }
.servers li { margin: 0; }

.server-chip { font-family: var(--mono); font-size: 12px; padding: 5px 9px; }
.server-chip small { color: var(--dim); font-family: inherit; }
.servers li.current .server-chip {
  border-color: var(--ok);
  color: var(--ok);
  cursor: default;
}
.servers li.current .server-chip small { color: var(--ok); opacity: .8; }

/* A target that failed its last probe: the reason a roster is dead is usually
   this, so it should be visible without opening anything. */
#target.unreachable { color: var(--err); }
.row { display: flex; gap: 8px; margin-bottom: 8px; }
.row:last-child { margin-bottom: 0; }
/* Buttons that share a row should divide it evenly. Without this the text sets
   each width, so a row of three is ragged and can overflow a 290px card. */
.row .grow { flex: 1; }

input {
  flex: 1; min-width: 0;
  background: var(--panel2); border: 1px solid var(--line); color: var(--text);
  border-radius: 7px; padding: 7px 10px; font: inherit; font-size: 13px;
}
input:focus { outline: none; border-color: var(--accent); }
input.narrow { flex: 0 0 74px; }

button {
  background: var(--panel2); border: 1px solid var(--line); color: var(--text);
  border-radius: 7px; padding: 7px 14px; font: inherit; font-size: 13px; cursor: pointer;
  transition: filter .15s, border-color .15s;
}
button:hover { filter: brightness(1.25); }
button.primary { background: var(--accent); border-color: var(--accent); color: #08111f; font-weight: 600; }
button.danger { background: transparent; border-color: var(--err); color: var(--err); }
button.ghost { background: transparent; color: var(--dim); }

/* sits after .clock, which already takes the auto margin */
#logout { margin-left: 10px; font-size: 12px; padding: 5px 10px; }

/* The language switch. Two small buttons rather than a <select>: the current
   language is then visible without opening anything, and it is one Tab away
   instead of three keystrokes. The active one is marked by colour and by
   aria-pressed, so it does not rely on colour alone. */
.lang { display: flex; gap: 2px; }
/* On the sign-in card the switch sits under the hint, centred, away from the
   form so it cannot be mistaken for the button that unlocks the panel. */
.login-lang { justify-content: center; margin-top: 18px; }
.langbtn {
  font-size: 11px; letter-spacing: .4px; padding: 4px 8px;
  font-variant-numeric: tabular-nums;
}
.langbtn.active { color: var(--text); border-color: var(--accent); background: var(--panel2); }

@media (max-width: 720px) {
  .langbtn { padding: 4px 6px; font-size: 10.5px; }
  header { gap: 10px; padding: 10px 12px; }
}

pre.output {
  margin: 10px 0 0; padding: 10px; min-height: 18px;
  background: #0c0e13; border: 1px solid var(--line); border-radius: 7px;
  font-family: var(--mono); font-size: 11.5px; color: var(--dim);
  white-space: pre-wrap; word-break: break-word; max-height: 170px; overflow: auto;
}
pre.output:empty { display: none; }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; flex: 1; min-height: 0; }
.col { display: flex; flex-direction: column; min-height: 0; }
.col h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--dim); margin: 0 0 8px; font-weight: 500; }
.feed {
  list-style: none; margin: 0; padding: 0; flex: 1; min-height: 0; overflow: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  font-family: var(--mono); font-size: 12px;
}
.feed li { padding: 6px 12px; border-bottom: 1px solid rgba(38,43,54,.5); display: flex; gap: 9px; }
.feed li:last-child { border-bottom: 0; }
.feed .ts { color: #5d6679; flex: 0 0 auto; }
.feed .who { color: var(--accent); flex: 0 0 auto; max-width: 150px; overflow: hidden; text-overflow: ellipsis; }
.feed .msg { color: var(--text); word-break: break-word; }
/* AuthMe likes to dump every account an IP ever made into one chat line. Clamp
   long messages so one of them cannot eat the whole feed; click to expand. */
.feed .msg.clamp { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; cursor: zoom-in; }
.feed .msg.clamp.open { display: block; cursor: zoom-out; }
.feed li.action .msg { color: var(--warn); }
.feed li.error .msg { color: var(--err); }
.feed .empty { color: var(--dim); justify-content: center; }

@media (max-width: 720px) {
  .split { grid-template-columns: 1fr; }
  .stats { flex-wrap: wrap; }
  .stat { flex: 1 0 33%; }
  .cards { grid-template-columns: 1fr; }
  /* The stats strip is 132px on a phone -- a sixth of the screen spent on
     counters that are already in the Roster. Compressed rather than hidden: it
     is still glanceable, and the vertical room is what the Stream pane needs. */
  .stat { padding: 5px 8px; }
  .stat .k { font-size: 9.5px; letter-spacing: .3px; }
  .stat .v { font-size: 15px; }
}

/* ------------------------------------------------------------------- login */
/* Same token palette as the panel so the two pages feel like one thing. */
.login-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}

.login {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 28px;
}

.login h1 {
  font-size: 1.05rem;
  letter-spacing: .02em;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 6px;
}

.login-sub {
  color: var(--dim);
  font-size: .85rem;
  margin: 0 0 20px;
}

.login label {
  display: block;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--dim);
  margin-bottom: 6px;
}

.login input {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .06em;
}

.login input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgb(90 160 255 / .18);
}

.login button.primary {
  width: 100%;
  margin-top: 14px;
  padding: 10px;
  background: var(--accent);
  color: #04101f;
  border: 0;
  border-radius: 8px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.login button.primary:hover { filter: brightness(1.08); }

.login-error {
  margin: 12px 0 0;
  color: var(--err);
  font-size: .85rem;
}

.login-hint {
  margin: 20px 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--dim);
  font-size: .76rem;
  line-height: 1.55;
}

.login-hint code {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: .92em;
}

/* ---------------------------------------------------------------- console */
/*
 * One bot's perception feed. Fixed-width timestamp and tag columns keep the
 * text edges aligned down the pane, which is what makes a kick stand out from
 * the chat around it when scanning.
 */
.console-head {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 10px; flex-wrap: wrap;
}

.console-head select {
  min-width: 260px; max-width: 46ch;
  font-family: var(--mono); font-size: 12.5px;
}

.feed.console {
  flex: 1; min-height: 0; overflow: auto;
  font-family: var(--mono); font-size: 12.5px;
}

.console-line { align-items: baseline; }
.console-line .ts { flex: 0 0 74px; }
.console-line .tag {
  flex: 0 0 44px; text-align: center;
  border-radius: 4px; padding: 0 5px;
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .4px;
  background: var(--panel2); color: var(--dim);
}
.console-line .txt { word-break: break-word; white-space: pre-wrap; }

/* Colour is meaning here: a kick must be findable at a glance in a wall of
 * chat, and an action bar should not look like something a player said. */
.console-line.k-kick .txt { color: var(--err); font-weight: 600; }
.console-line.k-kick .tag { background: rgba(240,97,109,.16); color: var(--err); }
.console-line.k-system .txt { color: var(--warn); }
.console-line.k-title .txt { color: var(--accent); }
.console-line.k-death .txt { color: var(--err); }
.console-line.k-actionbar .txt { color: var(--dim); font-style: italic; }
.console-line.k-join .txt,
.console-line.k-leave .txt { color: var(--dim); }

/* --------------------------------------------------------------- terminal */
.term {
  flex: 1; min-height: 0; overflow: auto;
  background: #0b0d11;
  border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.5;
}

.term-line { white-space: pre-wrap; word-break: break-word; }
.term-line.cmd { color: var(--accent); font-weight: 600; margin-top: 6px; }
.term-line.out { color: var(--text); }
.term-line.err { color: var(--err); }
.term-line.hint { color: var(--dim); font-style: italic; }
.term-line.meta { color: #5d6679; font-size: 11.5px; }

.term-form {
  display: flex; align-items: center; gap: 8px;
  margin-top: 10px;
  background: #0b0d11;
  border: 1px solid var(--line); border-radius: 10px;
  padding: 0 12px;
}
.term-form:focus-within { border-color: var(--accent); }
.term-form .prompt { color: var(--accent); font-family: var(--mono); font-size: 12.5px; }
.term-form input {
  flex: 1; border: 0; background: transparent; color: var(--text);
  font-family: var(--mono); font-size: 12.5px;
  padding: 11px 0; outline: none;
}

/* --------------------------------------------------------------- stream pane
 *
 * The stream is a video of a real client, so its container is sized like one:
 * the pane is as tall as the viewport allows and the iframe fills it, because a
 * game at 400px tall is a game you cannot see. The empty state sits behind the
 * frame rather than beside it so nothing shifts when the session starts.
 */
.stream-bar {
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.stream-bar .hint { color: var(--dim); font-size: 12px; }

.stream-wrap {
  position: relative;
  /* The client renders 854x480, so the container is 16:9 and nothing else: any
     other shape shows black bars, and a panel with bars looks like a video that
     failed to load rather than a game waiting for you. The max-width is what
     keeps it inside a short viewport without breaking the ratio -- capping the
     height alone would just reintroduce the bars sideways. */
  aspect-ratio: 16 / 9;
  width: 100%;
  /* The 340px is everything above and below the picture: two header rows, the
     stat strip, the tab strip, this pane's own toolbar and the chat box. Capping
     the *width* rather than the height is what preserves the ratio -- a
     max-height would simply squash it back into letterboxing. */
  max-width: calc((100vh - 340px) * 16 / 9);
  margin-inline: auto;
  /* Must not shrink: a flex child that shrinks gives up the ratio it just
     computed, and the picture goes back to being letterboxed in a 2.2:1 box. */
  flex: 0 0 auto;
  min-height: 200px;
  background: #000;
  border: 1px solid var(--line, #2a2e34);
  border-radius: 8px;
  overflow: hidden;
}
.stream-frame { width: 100%; height: 100%; border: 0; display: block; }
.stream-frame[hidden] { display: none; }
/* `hidden` is only `display: none` from the UA stylesheet, so an author rule
 * that gives the element a display value silently un-hides it. That is exactly
 * what happened here: "no stream running" sat on top of the live game. */
.stream-empty[hidden] { display: none; }
.stream-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--dim);
  font-size: 13px;
}
#pane-stream.active { display: flex; flex-direction: column; gap: 10px; }
#pane-stream .row { display: flex; gap: 8px; }
#pane-stream .row input { flex: 1; }
