/* BSC9000 control interface. Dark by design: it's the inside of the machine. */

:root {
  color-scheme: dark;

  --background: #0a0b0e;
  --surface: #121419;
  --surface-raised: #181b21;
  --surface-sunken: #0d0f13;
  --border: #23272f;
  --border-strong: #323843;

  --text: #e6e8ec;
  --text-muted: #8d95a3;
  --text-faint: #5f6673;

  --eye: #e3261b;
  --eye-bright: #ff4a3d;
  --eye-glow: rgba(227, 38, 27, 0.35);
  --eye-wash: rgba(227, 38, 27, 0.10);

  --steel: #8fb3d9;
  --steel-wash: rgba(143, 179, 217, 0.12);
  --amber: #f0b453;
  --amber-wash: rgba(240, 180, 83, 0.12);
  --green: #6fd39a;
  --green-wash: rgba(111, 211, 154, 0.11);
  --neutral-wash: rgba(141, 149, 163, 0.12);

  --radius: 12px;
  --radius-small: 8px;
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { scrollbar-color: var(--border-strong) var(--background); }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1200px 500px at 50% -200px, rgba(227, 38, 27, 0.07), transparent 70%),
    var(--background);
  color: var(--text);
  font: 15px/1.55 var(--font-sans);
}

a { color: var(--text); text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--eye); }
code { font-family: var(--font-mono); font-size: 0.86em; background: var(--surface-sunken); border: 1px solid var(--border); padding: 0.05em 0.35em; border-radius: 5px; }
strong { font-weight: 600; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 1.65rem; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 1.02rem; font-weight: 600; }
p { margin: 0.6rem 0; }

/* ---- Shared vocabulary ---- */

.eyebrow, .label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.small { font-size: 0.86rem; }
.center { text-align: center; }

/* ---- Top bar ---- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.65rem 1.25rem;
  background: rgba(10, 11, 14, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--eye) 50%, transparent);
  opacity: 0.55;
}
.brand { display: flex; align-items: center; gap: 0.6rem; text-decoration: none; }
.brand img { border-radius: 50%; box-shadow: 0 0 14px var(--eye-glow); }
.brand-name { font-family: var(--font-mono); font-weight: 700; letter-spacing: 0.16em; font-size: 0.92rem; }
.who { display: flex; align-items: center; gap: 0.75rem; }
.who form { margin: 0; }
.who-name { font-family: var(--font-mono); font-size: 0.8rem; color: var(--text-muted); }

main { max-width: 1000px; margin: 0 auto; padding: 1.75rem 1rem 7rem; }

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

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-head .crumbs { margin-bottom: 0.45rem; }
.page-head .lede { margin: 0.4rem 0 0; color: var(--text-muted); max-width: 46rem; }
.page-actions { display: flex; gap: 0.5rem; }
.page-actions form { margin: 0; }
.crumbs { font-family: var(--font-mono); font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-faint); }
.crumbs a { color: var(--text-muted); text-decoration: none; }
.crumbs a:hover { color: var(--text); }
.crumbs .separator { margin: 0 0.4rem; }
.glyph { color: var(--text-faint); font-weight: 400; margin-right: 0.35rem; }

/* ---- Panels ---- */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.35rem;
  margin: 0 0 1rem;
}
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: 0.9rem; }
.panel-head .label { white-space: nowrap; }
.panel > :last-child { margin-bottom: 0; }
.subhead { font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-muted); margin: 1.4rem 0 0.6rem; }

.empty {
  margin: 0;
  padding: 1.4rem 1rem;
  text-align: center;
  color: var(--text-muted);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-small);
  font-family: var(--font-mono);
  font-size: 0.82rem;
}

/* ---- Buttons ---- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 1px solid var(--border-strong);
  background: var(--surface-raised);
  color: var(--text);
  border-radius: var(--radius-small);
  padding: 0.5rem 1rem;
  font: 500 0.92rem var(--font-sans);
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.button:hover { border-color: var(--text-faint); background: #1f232a; }
.button-primary { background: var(--eye); border-color: var(--eye); color: #fff; font-weight: 600; }
.button-primary:hover { background: var(--eye-bright); border-color: var(--eye-bright); box-shadow: 0 0 18px var(--eye-glow); }
.button-quiet { background: transparent; border-color: transparent; color: var(--text-muted); }
.button-quiet:hover { background: var(--surface-raised); border-color: var(--border); color: var(--text); }
.button-danger { background: transparent; border-color: rgba(227, 38, 27, 0.45); color: var(--eye-bright); }
.button-danger:hover { background: var(--eye-wash); border-color: var(--eye); }

:focus-visible { outline: 2px solid var(--eye-bright); outline-offset: 2px; }

/* ---- Banners ---- */

.banner {
  margin: 0 0 1rem;
  padding: 0.7rem 0.95rem;
  border-radius: var(--radius-small);
  border: 1px solid var(--border);
  border-left-width: 3px;
  background: var(--surface);
}
.banner-success { border-left-color: var(--green); background: linear-gradient(90deg, var(--green-wash), var(--surface) 60%); }
.banner-info { border-left-color: var(--steel); background: linear-gradient(90deg, var(--steel-wash), var(--surface) 60%); }
.banner-error { border-left-color: var(--eye); background: linear-gradient(90deg, var(--eye-wash), var(--surface) 60%); }

/* ---- Pills ---- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  white-space: nowrap;
  background: var(--neutral-wash);
  color: var(--text-muted);
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.85; }
.pill-on { background: var(--eye-wash); color: var(--eye-bright); }
.pill-on::before { box-shadow: 0 0 6px var(--eye); animation: watching 2.4s ease-in-out infinite; }
.pill-dry-run, .pill-warned { background: var(--amber-wash); color: var(--amber); }
.pill-relocated { background: var(--steel-wash); color: var(--steel); }
.pill-removed { background: var(--eye-wash); color: var(--eye-bright); }
.pill-observed, .pill-off { background: var(--neutral-wash); color: var(--text-muted); }

@keyframes watching {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 1; }
}

/* ---- Gate (login, errors) ---- */

.gate { max-width: 460px; margin: 9vh auto 0; text-align: center; }
.gate .panel { padding: 2rem 1.75rem; }
.gate-eye { width: 112px; height: 112px; border-radius: 50%; margin: 0 auto 1.25rem; display: block; animation: gaze 5s ease-in-out infinite; }
.gate-eye.small { width: 72px; height: 72px; }
.gate h1 { font-family: var(--font-mono); letter-spacing: 0.18em; font-size: 1.35rem; }
.gate .eyebrow { margin-top: 0.35rem; }
.gate p { color: var(--text-muted); }
.gate form { margin-top: 1.4rem; }
.gate .button-primary { width: 100%; padding: 0.7rem 1rem; }
.gate .banner { text-align: left; }
.gate .message { color: var(--text); margin: 0.75rem 0 1.4rem; }

@keyframes gaze {
  0%, 100% { box-shadow: 0 0 28px rgba(227, 38, 27, 0.25); }
  50% { box-shadow: 0 0 52px rgba(227, 38, 27, 0.55); }
}

/* ---- Servers ---- */

.guilds { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.75rem; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.guild {
  display: flex; align-items: center; gap: 0.85rem;
  padding: 0.9rem 1rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); text-decoration: none; font-weight: 600;
  transition: border-color 0.15s, background 0.15s;
}
.guild:hover { border-color: var(--border-strong); background: var(--surface-raised); }
.guild img, .guild-initial { width: 42px; height: 42px; border-radius: 50%; flex: none; }
.guild-initial { display: grid; place-items: center; background: var(--surface-sunken); border: 1px solid var(--border); color: var(--text-muted); font-family: var(--font-mono); }
.chevron { margin-left: auto; color: var(--text-faint); }

/* ---- Channel list ---- */

.channel-group + .channel-group { margin-top: 1.1rem; }
.channel-group .subhead { margin-top: 0; }
.channels { list-style: none; padding: 0; margin: 0; border: 1px solid var(--border); border-radius: var(--radius-small); overflow: hidden; }
.channels li + li { border-top: 1px solid var(--border); }
.channel-row {
  display: grid;
  grid-template-columns: minmax(170px, 280px) 7.5rem 1fr auto;
  align-items: center;
  gap: 0.3rem 1rem;
  padding: 0.65rem 0.85rem;
  color: var(--text);
  text-decoration: none;
  background: var(--surface-sunken);
  transition: background 0.15s;
}
.channel-row:hover { background: var(--surface-raised); }
.channel-name { display: flex; align-items: baseline; min-width: 0; font-weight: 600; }
.channel-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.channel-summary { color: var(--text-muted); font-size: 0.88rem; }
.tag { flex: none; font-family: var(--font-mono); font-size: 0.64rem; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-faint); border: 1px solid var(--border-strong); border-radius: 4px; padding: 0.05rem 0.3rem; margin-left: 0.5rem; align-self: center; }
.channel-warning { grid-column: 1 / -1; color: var(--eye-bright); font-size: 0.8rem; font-family: var(--font-mono); }

/* ---- Interventions log ---- */

.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
  font-weight: 500;
  padding: 0 0.65rem 0.55rem;
  border-bottom: 1px solid var(--border-strong);
}
td { padding: 0.65rem; border-bottom: 1px solid var(--border); vertical-align: top; }
tbody tr:last-child td { border-bottom: none; }
.log td { font-size: 0.9rem; }
.log time { font-family: var(--font-mono); font-size: 0.82rem; color: var(--text-muted); white-space: nowrap; }
.log td:nth-child(2) { white-space: nowrap; }
.log td:nth-child(4) { min-width: 9.5rem; }
.log .excerpt { max-width: 300px; overflow-wrap: anywhere; color: var(--text-muted); }
.log .excerpt a { font-family: var(--font-mono); font-size: 0.78rem; white-space: nowrap; }
.problem { max-width: 17rem; color: var(--eye-bright); margin-top: 0.3rem; font-family: var(--font-mono); font-size: 0.78rem; }
.fallback-note { margin-top: 0.3rem; font-family: var(--font-mono); font-size: 0.75rem; color: var(--text-faint); }

/* ---- Policy form ---- */

.rule-preview {
  margin: 1rem 0 0;
  padding: 0.75rem 0.95rem;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-left: 3px solid var(--eye);
  border-radius: var(--radius-small);
  color: var(--text-muted);
}
.rule-preview strong { color: var(--text); }

.field { margin: 1rem 0; }
.field > label, legend { display: block; font-weight: 600; font-size: 0.92rem; margin-bottom: 0.35rem; }
.field > label.subhead { font-weight: 400; font-size: 0.72rem; margin: 1.4rem 0 0.6rem; }
.hint + .table-scroll { margin-top: 0.75rem; }
.hint { margin: 0.35rem 0 0; font-size: 0.84rem; color: var(--text-muted); }
.field-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 1.25rem; }
.with-unit { display: flex; align-items: center; gap: 0.5rem; color: var(--text-muted); }
.with-unit input { width: 6.5rem; }
fieldset { border: none; padding: 0; margin: 1rem 0; }

input[type="text"], input[type="number"], textarea, select {
  font: inherit;
  color: var(--text);
  background: var(--surface-sunken);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-small);
  padding: 0.5rem 0.65rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input[type="text"], textarea { width: 100%; }
select { min-width: 14rem; }
textarea { resize: vertical; line-height: 1.5; }
input[type="text"]:focus, input[type="number"]:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--eye);
  box-shadow: 0 0 0 3px var(--eye-wash);
}
input[type="checkbox"], input[type="radio"] { accent-color: var(--eye); width: 1.05rem; height: 1.05rem; margin: 0; }

.kinds td { padding: 0.55rem 0.65rem; vertical-align: middle; }
.kinds td:not(:first-child), .kinds th:not(:first-child) { width: 6.5rem; text-align: center; }
.kinds tbody tr:hover { background: var(--surface-raised); }
.kind-description { font-size: 0.82rem; color: var(--text-muted); margin-top: 0.1rem; }

.check-row, .option { display: flex; gap: 0.75rem; align-items: flex-start; margin: 0.85rem 0; cursor: pointer; }
.check-row input, .option input { margin-top: 0.22rem; flex: none; }
.option-text strong { display: block; }
.option-text .muted { display: block; font-size: 0.87rem; margin-top: 0.1rem; }

.options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.65rem; }
.options .option {
  margin: 0;
  padding: 0.85rem 0.95rem;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.options .option:hover { border-color: var(--border-strong); }
.options .option:has(input:checked) { border-color: var(--eye); box-shadow: 0 0 0 1px var(--eye), 0 0 22px rgba(227, 38, 27, 0.14); }

.relocate-settings[hidden] { display: none; }

.switch-row { display: flex; gap: 0.95rem; align-items: center; cursor: pointer; }
.switch-row input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch {
  flex: none; position: relative;
  width: 2.75rem; height: 1.55rem; border-radius: 999px;
  background: var(--surface-sunken); border: 1px solid var(--border-strong);
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 1.1rem; height: 1.1rem; border-radius: 50%;
  background: var(--text-muted);
  transition: transform 0.15s, background 0.15s;
}
.switch-row input:checked + .switch { background: var(--eye); border-color: var(--eye); box-shadow: 0 0 16px var(--eye-glow); }
.switch-row input:checked + .switch::after { transform: translateX(1.2rem); background: #fff; }
.switch-row input:focus-visible + .switch { outline: 2px solid var(--eye-bright); outline-offset: 2px; }

.roles { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.role {
  display: inline-flex; align-items: center; gap: 0.45rem;
  padding: 0.3rem 0.75rem;
  background: var(--surface-sunken); border: 1px solid var(--border); border-radius: 999px;
  font-size: 0.88rem; cursor: pointer;
}
.role:has(input:checked) { border-color: var(--eye); }
.role-dot { width: 0.65rem; height: 0.65rem; border-radius: 50%; background: var(--text-faint); }

.save-bar {
  position: sticky; bottom: 1rem; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
  margin-top: 1.25rem;
  padding: 0.75rem 0.9rem 0.75rem 1.1rem;
  background: rgba(18, 20, 25, 0.92);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
}
.save-bar .label { color: var(--text-faint); }
.save-bar .actions { display: flex; gap: 0.5rem; }

/* ---- Small screens ---- */

@media (max-width: 680px) {
  main { padding-top: 1.25rem; }
  .panel { padding: 1rem; }
  .topbar { padding: 0.6rem 1rem; }
  .who-name { display: none; }
  .options { grid-template-columns: 1fr; }
  .channel-row { grid-template-columns: 1fr auto; }
  .channel-row .chevron { display: none; }
  .channel-summary { grid-column: 1 / -1; }
  .save-bar .label { display: none; }
  .save-bar { justify-content: flex-end; }
  select { min-width: 0; width: 100%; }
  .kinds td:not(:first-child), .kinds th:not(:first-child) { width: 4.5rem; }
  .kinds th { padding-left: 0.3rem; padding-right: 0.3rem; }
  .log td:nth-child(4) { min-width: 0; }
  .problem { max-width: none; }
  .log thead { display: none; }
  .log tr { display: block; padding: 0.7rem 0; border-bottom: 1px solid var(--border); }
  .log tbody tr:last-child { border-bottom: none; }
  .log td { display: grid; grid-template-columns: 5.5rem 1fr; gap: 0.5rem; border: none; padding: 0.15rem 0; }
  .log td:nth-child(2) { white-space: normal; }
  .log td::before { content: attr(data-label); font-family: var(--font-mono); font-size: 0.68rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-faint); padding-top: 0.15rem; }
  .log .excerpt { max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
