/* BlueCity GM console.
 *
 * One stylesheet for both language pages and the sign-in page. The console is
 * a top-tab workspace: a fixed header holding the identity and the role the
 * operator is acting on, a tab strip under it, and one visible view at a time.
 */

:root {
  color-scheme: dark;

  --bg: #0b0d11;
  --bg-grad: radial-gradient(1200px 620px at 72% -180px, #1a2436 0%, #0b0d11 62%);
  --panel: #12161d;
  --panel-2: #171c25;
  --panel-3: #1e242f;
  --line: #232a35;
  --line-2: #323b49;

  --text: #e7ebf2;
  --text-dim: #b3bcca;
  --muted: #7f8a9b;

  --accent: #5b8cff;
  --accent-ink: #06101f;
  --accent-soft: rgba(91, 140, 255, 0.14);
  --accent-line: rgba(91, 140, 255, 0.42);

  --ok: #3fd0a2;
  --ok-ink: #032018;
  --ok-soft: rgba(63, 208, 162, 0.13);
  --warn: #e6b45e;
  --danger: #f2697c;
  --danger-soft: rgba(242, 105, 124, 0.13);

  --radius: 12px;
  --radius-sm: 8px;
  --control: 36px;
  --panel-tall: 560px;
  /* Everything living in the header shares one height, or the row reads as a
   * pile of differently sized chips. */
  --control-bar: 32px;
  --mono: "Cascadia Mono", Consolas, "SF Mono", "Roboto Mono", monospace;
  --sans: Inter, "Segoe UI Variable", "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg-grad) fixed;
  color: var(--text);
  font: 14px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

::selection { background: var(--accent-soft); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-2); border: 3px solid transparent; background-clip: padding-box; border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #46516180; background-clip: padding-box; }

/* ---------------------------------------------------------------- brand -- */

/* Identity never gives up room; it is the one thing that must stay readable. */
.brand { display: flex; flex: 0 0 auto; align-items: center; gap: 10px; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  border-radius: 9px;
  background: linear-gradient(140deg, #6f9bff, #3861cf);
  box-shadow: 0 6px 18px rgba(56, 97, 207, 0.38);
  color: #fff;
  font-weight: 800;
  font-size: 15px;
}

.brand-name { font-size: 14px; font-weight: 650; letter-spacing: -0.1px; line-height: 1.2; white-space: nowrap; }
.brand-sub { color: var(--muted); font-size: 11px; line-height: 1.2; white-space: nowrap; }

/* --------------------------------------------------------------- header -- */

.shell { display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 11px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(11, 13, 17, 0.86);
  backdrop-filter: blur(14px);
}

.topbar-role {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  margin-left: 6px;
  padding-left: 18px;
  border-left: 1px solid var(--line);
}

.topbar-role > input { flex: 0 1 150px; min-width: 104px; font-variant-numeric: tabular-nums; }


/* Only messages land here -- "no save", "not a UID" -- so the header stays one
 * line and a long one is trimmed rather than wrapping the bar. */
#roleStatus { min-width: 0; overflow: hidden; flex-wrap: nowrap; }
#roleStatus .msg { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.account-chip {
  max-width: 240px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: var(--control-bar);
  padding: 0 11px;
  border: 1px solid rgba(63, 208, 162, 0.32);
  border-radius: 999px;
  background: var(--ok-soft);
  color: var(--ok);
  font-size: 12px;
  white-space: nowrap;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 3px rgba(63, 208, 162, 0.16);
}

.icon-link {
  display: inline-flex;
  white-space: nowrap;
  align-items: center;
  height: var(--control-bar);
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 12px;
  text-decoration: none;
}

.icon-link:hover { border-color: var(--line-2); color: var(--text); }

/* ----------------------------------------------------------------- tabs -- */

.tabbar {
  position: sticky;
  top: 59px;
  z-index: 20;
  display: flex;
  gap: 2px;
  overflow-x: auto;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(11, 13, 17, 0.86);
  backdrop-filter: blur(14px);
  scrollbar-width: none;
}

.tabbar::-webkit-scrollbar { display: none; }

.tab {
  position: relative;
  flex: 0 0 auto;
  padding: 12px 14px 13px;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}

.tab:hover { color: var(--text-dim); }

.tab[aria-selected="true"] { color: var(--text); }

.tab[aria-selected="true"]::after {
  content: "";
  position: absolute;
  right: 12px;
  bottom: -1px;
  left: 12px;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--accent);
}

/* ----------------------------------------------------------------- main -- */

.main { width: min(100%, 1320px); margin: 0 auto; padding: 24px 24px 64px; }

.view { display: none; }
.view.is-active { display: block; animation: view-in 0.16s ease-out; }

@keyframes view-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

.view-head { margin: 0 0 18px; }
.view-head h1 { margin: 0; font-size: 19px; font-weight: 650; letter-spacing: -0.2px; }
.view-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

/* Stretch, not start: the panels of a row share one top and one bottom edge. */
.cols { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols.one { grid-template-columns: minmax(0, 1fr); }
.span-all { grid-column: 1 / -1; }

/* ---------------------------------------------------------------- cards -- */

.panel {
  display: flex;
  flex-direction: column;
  padding: 17px 18px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.02) inset, 0 10px 26px rgba(0, 0, 0, 0.22);
}

/* A panel holding a long list is given a height rather than taking one from
 * its contents, so the row it sits in has a predictable bottom edge. The list
 * inside absorbs whatever height is left over. */
.panel-fixed { height: var(--panel-tall); }

/* Panels live in a grid, which already spaces them. An adjacent-sibling margin
 * here would also apply across grid columns and push every panel but the first
 * of a row down by itself, so the tops of a row stopped lining up. */
#notFound { margin-bottom: 18px; }

.panel h2 {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 0 0 14px;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.2px;
}

.panel h2 .muted,
.panel h2 .hint { flex: 1; color: var(--muted); font-size: 11.5px; font-weight: 400; letter-spacing: 0; }

.panel h2 button { margin-left: auto; align-self: center; }

.subhead {
  margin: 16px 0 10px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--muted);
}

.subhead:first-child { margin-top: 0; padding-top: 0; border-top: 0; }

/* ------------------------------------------------------------- controls -- */

button, input, select, textarea { font: inherit; }

input[type="text"], input[type="number"], input[type="email"], input[type="password"], select, textarea {
  height: var(--control);
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel-3);
  color: var(--text);
  font-size: 13px;
  transition: border-color 0.14s, box-shadow 0.14s;
}

textarea { height: auto; padding: 9px 11px; width: 100%; resize: vertical; line-height: 1.55; }

input::placeholder, textarea::placeholder { color: #66707f; }

input:focus, select:focus, textarea:focus {
  outline: 0;
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

input:disabled, select:disabled, textarea:disabled { opacity: 0.45; cursor: not-allowed; }

select {
  appearance: none;
  padding-right: 30px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path d='M2.5 4.5L6 8l3.5-3.5' fill='none' stroke='%237f8a9b' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

button, a.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: var(--control);
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: filter 0.14s, background 0.14s, border-color 0.14s, opacity 0.14s;
}

button:hover, a.button:hover { filter: brightness(1.09); }
button:active { filter: brightness(0.94); }
button:focus-visible { outline: 0; box-shadow: 0 0 0 3px var(--accent-soft); }

button.ghost {
  border-color: var(--line-2);
  background: transparent;
  color: var(--text-dim);
  font-weight: 500;
}

button.ghost:hover { border-color: #47536580; background: rgba(255, 255, 255, 0.035); color: var(--text); filter: none; }

button.green { background: var(--ok); color: var(--ok-ink); }

button.danger { border-color: rgba(242, 105, 124, 0.4); background: var(--danger-soft); color: var(--danger); }
button.danger:hover { background: rgba(242, 105, 124, 0.2); filter: none; }

button.solid-danger { background: var(--danger); color: #2a0a10; }

button:disabled { cursor: not-allowed; filter: grayscale(0.45); opacity: 0.5; }

button.small { height: 28px; padding: 0 9px; font-size: 12px; }

/* Header controls share one height. This sits after the base control rules
 * rather than up with the header, because it has the same specificity as
 * `input[type="text"]` and only wins on source order. */
.topbar input,
.topbar select,
.topbar button,
.topbar .icon-link,
.topbar .status-pill { height: var(--control-bar); }

label { color: var(--muted); font-size: 12px; white-space: nowrap; }

.check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: var(--control);
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
}

.check input { width: 15px; height: 15px; accent-color: var(--accent); }

.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; }
.row:last-child { margin-bottom: 0; }
.row > label { flex: 0 0 auto; }
.row input[type="text"], .row input[type="email"], .row input[type="password"] { flex: 1 1 150px; min-width: 0; }
.row input[type="number"] { width: 116px; flex: 0 0 auto; }
.row select { flex: 0 1 auto; min-width: 150px; max-width: 100%; }
.row .grow { flex: 1 1 auto; }

.field-label { flex: 0 0 74px; color: var(--muted); font-size: 12px; }

.note { margin: -2px 0 11px; color: var(--muted); font-size: 11.5px; line-height: 1.5; }

.msg { min-height: 17px; margin-top: 9px; font-size: 12.5px; }
.msg.ok { color: var(--ok); }
.msg.err { color: var(--danger); }

.empty { padding: 14px 0; color: var(--muted); font-size: 13px; }

/* ---------------------------------------------------------------- stats -- */

.stats { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }

.stat {
  display: inline-flex;
  flex-direction: column;
  gap: 1px;
  min-width: 86px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.018);
}

.stat .k { color: var(--muted); font-size: 11px; letter-spacing: 0.2px; }
.stat .v { font-size: 15px; font-weight: 620; font-variant-numeric: tabular-nums; }

.stats.inline-stats { margin: 0; }

.stats.inline-stats .stat {
  flex-direction: row;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
  padding: 4px 10px;
  white-space: nowrap;
}

.stats.inline-stats .stat .v { font-size: 13px; }

.tag {
  display: inline-block;
  padding: 1px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}

.tag.on { background: var(--ok-soft); color: var(--ok); }
.tag.off { background: var(--danger-soft); color: var(--danger); }

/* --------------------------------------------------------------- tables -- */

.table-wrap {
  flex: 1 1 auto;
  min-height: 120px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

table { width: 100%; border-collapse: collapse; font-size: 13px; }

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 9px 12px;
  background: var(--panel-3);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-align: left;
  text-transform: uppercase;
}

tbody td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(255, 255, 255, 0.022); }

td .meta { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
td.num { font-variant-numeric: tabular-nums; }
td.right { text-align: right; }

/* ----------------------------------------------------------- characters -- */

.grid-chars {
  display: grid;
  flex: 1 1 auto;
  gap: 8px;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  grid-auto-rows: min-content;
  min-height: 120px;
  overflow: auto;
  padding-right: 4px;
}

.char-card {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel-3);
}

.char-card .cid { font-size: 13px; font-weight: 600; }
.char-card .meta { color: var(--muted); font-size: 11px; }
.char-card button { margin-top: 7px; height: 28px; font-size: 12px; }

/* A grid of thirty identical filled buttons reads as noise, so the action is
 * tinted rather than solid. */
.char-card button.green {
  border-color: rgba(63, 208, 162, 0.3);
  background: var(--ok-soft);
  color: var(--ok);
}

.char-card button.green:hover { background: rgba(63, 208, 162, 0.22); filter: none; }
.char-card.locked { background: rgba(255, 255, 255, 0.012); opacity: 0.74; }
.char-card.locked:hover { opacity: 1; }

/* -------------------------------------------------------------- console -- */

.command-input { flex: 1 1 280px; font-family: var(--mono); }

.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 2px 0 10px; }
.chips .chip-label { margin-right: 2px; color: var(--muted); font-size: 12px; }

.chips button {
  height: 26px;
  padding: 0 9px;
  border-color: var(--line);
  background: var(--panel-3);
  color: var(--text-dim);
  font: 12px/1 var(--mono);
  font-weight: 500;
}

.chips button:hover { border-color: var(--line-2); color: var(--text); filter: none; }

.output {
  max-height: 300px;
  min-height: 64px;
  margin: 10px 0 0;
  overflow: auto;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #090b0f;
  color: var(--text-dim);
  font: 12.5px/1.6 var(--mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.code-editor {
  min-height: 190px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.6;
  tab-size: 2;
}

/* ---------------------------------------------------------------- login -- */

body.login-page { display: grid; place-items: center; padding: 24px; }

.login {
  width: min(392px, 100%);
  padding: 26px 26px 22px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
}

.login-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.login-head h1 { margin: 0; font-size: 17px; font-weight: 650; }
.login-head p { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }
.login label { display: block; margin: 0 0 6px; white-space: normal; }
.login input { width: 100%; margin-bottom: 14px; }
.login button { width: 100%; }
.login .msg { text-align: center; }
.login .oauth { display: flex; width: 100%; text-decoration: none; }
.login-divider { margin: 14px 0; text-align: center; color: var(--muted); font-size: 12.5px; }

/* ------------------------------------------------------------ responsive */

@media (max-width: 1000px) {
  .cols { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 820px) {
  .topbar { flex-wrap: wrap; gap: 10px; padding: 10px 16px; }
  .topbar-role { order: 3; width: 100%; margin: 0; padding: 0; border-left: 0; }
  .topbar-role > select { flex: 1 1 auto; min-width: 0; }
  .topbar-actions { margin-left: auto; }
  .account-chip { display: none; }
  .tabbar { top: 0; padding: 0 10px; }
  .main { padding: 18px 14px 48px; }
  .panel-fixed { height: 440px; }
}
