/**
 * TAHR7 Admin.
 *
 * Same visual language as the hub, tuned for a tool rather than a gallery:
 * denser rows, monospace for anything that is an identifier, and colour used
 * only to mean something (red destroys, yellow warns, cyan is informational).
 */

:root {
  --yellow:      #f9ec31;
  --yellow-dim:  #c9be26;
  --yellow-glow: rgba(249, 236, 49, 0.16);

  --bg:          #0c0c0e;
  --surface:     #17171a;
  --surface-2:   #1e1e21;
  --surface-3:   #26262a;

  --ink:         #f2f2f3;
  --ink-dim:     #a0a0a8;
  --ink-faint:   #6a6a74;

  --edge:        rgba(255, 255, 255, 0.09);
  --edge-hi:     rgba(255, 255, 255, 0.2);

  --red:         #ff5a5a;
  --green:       #7ee787;
  --cyan:        #59d5e0;
  --violet:      #b191ff;

  --radius:      4px;
  --radius-lg:   8px;

  --sans: "Inter", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --bar-h: 56px;
}

* { box-sizing: border-box; }

/* Author `display` rules beat the UA stylesheet's rule for [hidden], so a
   `.gate { display: grid }` keeps rendering an element the JS believes it has
   hidden. Here that put an invisible full-screen overlay on top of the page.
   One line, and every `hidden` in the markup means what it says. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* The faint hex lattice behind everything. Fixed and pointer-transparent, so it
   never intercepts a click or scrolls out from under the content. */
.hexfield {
  position: fixed;
  inset: -20%;
  pointer-events: none;
  z-index: 0;
  opacity: 0.5;
  background-image:
    linear-gradient(115deg, transparent 49.6%, var(--edge) 49.6%, var(--edge) 50.4%, transparent 50.4%),
    linear-gradient(65deg, transparent 49.6%, var(--edge) 49.6%, var(--edge) 50.4%, transparent 50.4%);
  background-size: 46px 80px;
  mask-image: radial-gradient(ellipse 90% 60% at 50% 0%, #000 0%, transparent 75%);
}

a { color: inherit; }
.muted { color: var(--ink-dim); font-size: 13.5px; margin: 0 0 14px; line-height: 1.55; }
.err { min-height: 18px; margin: 8px 0 0; font-family: var(--mono); font-size: 12px; color: var(--red); }
.mono { font-family: var(--mono); font-size: 12px; }

/* ── boot ───────────────────────────────────────────────────────────────── */

.boot {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-content: center; justify-items: center; gap: 14px;
  background: var(--bg); color: var(--yellow);
  transition: opacity 0.4s var(--ease);
}
.boot.fading { opacity: 0; pointer-events: none; }
.boot-mark { animation: pulse 1.6s ease-in-out infinite; }
.boot-text { margin: 0; font-family: var(--mono); font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--ink-faint); }
@keyframes pulse { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; } }

/* ── gates ──────────────────────────────────────────────────────────────── */

.gate { position: relative; z-index: 1; display: grid; place-items: center; min-height: 100vh; padding: 40px 20px; }
.gate-inner { width: 100%; max-width: 460px; text-align: center; }
.gate-mark { color: var(--yellow); filter: drop-shadow(0 0 26px var(--yellow-glow)); }

.wordmark { margin: 18px 0 0; font-size: clamp(38px, 9vw, 58px); font-weight: 850; letter-spacing: -0.03em; line-height: 1; }
.wordmark span { color: var(--yellow); }
.wordmark-sub { margin: 4px 0 0; font-family: var(--mono); font-size: 12px; letter-spacing: 0.42em; color: var(--ink-faint); }
.tagline { margin: 18px auto 24px; max-width: 380px; color: var(--ink-dim); font-size: 14px; }

.discord-btn {
  display: inline-flex; align-items: center; gap: 11px;
  padding: 13px 26px; border: 1px solid var(--edge-hi); border-radius: var(--radius);
  background: #5865f2; color: #fff; text-decoration: none; font-weight: 650;
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease), background 0.2s;
}
.discord-btn:hover { background: #6b76f5; transform: translateY(-2px); box-shadow: 0 14px 34px -12px rgba(88,101,242,0.9); }

.gate-note { min-height: 20px; margin: 16px 0 0; font-family: var(--mono); font-size: 12px; color: var(--red); }
.gate-facts { list-style: none; margin: 40px 0 0; padding: 0; text-align: left; display: grid; gap: 12px; }
.gate-facts li { display: grid; gap: 2px; padding: 11px 14px; border: 1px solid var(--edge); border-left: 2px solid var(--yellow); border-radius: var(--radius); background: var(--surface); }
.gate-facts b { font-size: 12.5px; }
.gate-facts span { font-size: 12.5px; color: var(--ink-dim); }

.mfagate-title { margin: 0; font-size: 26px; font-weight: 800; }
.mfagate-form { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.mfagate-hint { margin: 14px 0 20px; font-size: 12.5px; color: var(--ink-faint); }
#enroll .btn { margin: 0 5px; }

.code-input {
  width: 190px; padding: 12px 14px;
  border: 1px solid var(--edge-hi); border-radius: var(--radius);
  background: #000; color: var(--yellow);
  font-family: var(--mono); font-size: 21px; letter-spacing: 0.22em; text-align: center;
}
.code-input:focus { outline: none; border-color: var(--yellow); box-shadow: 0 0 0 3px var(--yellow-glow); }

/* ── chrome ─────────────────────────────────────────────────────────────── */

.app { position: relative; z-index: 1; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 18px;
  height: var(--bar-h); padding: 0 clamp(14px, 3vw, 26px);
  border-bottom: 1px solid var(--edge);
  background: rgba(12, 12, 14, 0.92);
  backdrop-filter: blur(14px);
}
.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; color: var(--yellow); flex-shrink: 0; }
.brand-text { font-family: var(--mono); font-size: 12px; letter-spacing: 0.2em; color: var(--ink); }

.tabs { display: flex; gap: 2px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  position: relative; flex-shrink: 0;
  padding: 8px 14px; border: none; background: none;
  color: var(--ink-faint); font-family: inherit; font-weight: 650; font-size: 12.5px;
  letter-spacing: 0.04em; text-transform: uppercase; cursor: pointer; transition: color 0.2s;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--yellow); }
.tab[aria-selected="true"]::after {
  content: ""; position: absolute; left: 12px; right: 12px; bottom: -1px;
  height: 2px; background: var(--yellow); box-shadow: 0 0 12px var(--yellow);
}

.topbar-right { display: flex; align-items: center; gap: 10px; margin-left: auto; flex-shrink: 0; }
.guild-chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 11px; border: 1px solid var(--edge); border-radius: 100px;
  font-size: 12px; color: var(--ink-dim); max-width: 210px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.guild-chip img { width: 18px; height: 18px; border-radius: 50%; flex-shrink: 0; }

.pill {
  padding: 4px 10px; border-radius: 100px;
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.06em;
  border: 1px solid var(--edge); background: var(--surface-2); color: var(--ink-dim);
}
.fresh-pill { border-color: rgba(126,231,135,0.3); color: var(--green); }
.fresh-pill.stale { border-color: rgba(249,236,49,0.3); color: var(--yellow); }

.avatar-btn { padding: 0; border: 1px solid var(--edge-hi); border-radius: 50%; background: none; cursor: pointer; line-height: 0; }
.avatar-btn img { width: 30px; height: 30px; border-radius: 50%; display: block; background: var(--surface-2); }

.warnbar {
  display: flex; align-items: center; gap: 10px;
  padding: 9px clamp(14px, 3vw, 26px);
  border-bottom: 1px solid rgba(249, 236, 49, 0.24);
  background: rgba(249, 236, 49, 0.07);
  color: var(--yellow); font-size: 12.5px;
}

.view { padding: clamp(16px, 3vw, 26px); max-width: 1180px; margin: 0 auto; }

/* ── buttons and fields ─────────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border: 1px solid var(--edge); border-radius: var(--radius);
  background: var(--surface-2); color: var(--ink);
  font-family: inherit; font-size: 13px; font-weight: 620;
  cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background 0.18s, border-color 0.18s, color 0.18s, opacity 0.18s;
}
.btn:hover:not(:disabled) { background: var(--surface-3); border-color: var(--edge-hi); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.primary { background: var(--yellow); border-color: var(--yellow); color: #14140b; font-weight: 720; }
.btn.primary:hover:not(:disabled) { background: #fff36b; border-color: #fff36b; }
.btn.ghost { background: transparent; }
.btn.danger { border-color: rgba(255,90,90,0.4); color: var(--red); }
.btn.danger:hover:not(:disabled) { background: rgba(255,90,90,0.12); border-color: var(--red); }
.btn.small { padding: 5px 10px; font-size: 12px; }

.icon-btn {
  display: grid; place-items: center; width: 30px; height: 30px;
  border: 1px solid var(--edge); border-radius: var(--radius);
  background: var(--surface-2); color: var(--ink-dim);
  font-size: 17px; line-height: 1; cursor: pointer; flex-shrink: 0;
}
.icon-btn:hover { color: var(--ink); border-color: var(--edge-hi); }

.field {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--edge); border-radius: var(--radius);
  background: var(--surface); color: var(--ink);
  font-family: inherit; font-size: 13.5px;
}
.field:focus { outline: none; border-color: var(--yellow); box-shadow: 0 0 0 3px var(--yellow-glow); }
select.field { cursor: pointer; }
textarea.field { resize: vertical; min-height: 62px; }
.field-label { display: grid; gap: 5px; font-family: var(--mono); font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-faint); }

/* ── search + rows ──────────────────────────────────────────────────────── */

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .field { flex: 1; min-width: 190px; }
.count { font-family: var(--mono); font-size: 11.5px; color: var(--ink-faint); margin-left: auto; }

.rows { display: grid; gap: 6px; }
.row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 13px;
  border: 1px solid var(--edge); border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer; text-align: left; width: 100%;
  font-family: inherit; color: inherit; font-size: inherit;
  transition: border-color 0.18s, background 0.18s;
}
.row:hover { border-color: var(--edge-hi); background: var(--surface-2); }
.row-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--surface-3); flex-shrink: 0; }
.row-main { flex: 1; min-width: 0; display: grid; gap: 1px; }
.row-name { font-weight: 640; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { font-family: var(--mono); font-size: 11px; color: var(--ink-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-tags { display: flex; gap: 5px; flex-wrap: wrap; justify-content: flex-end; flex-shrink: 0; }

.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 100px;
  border: 1px solid var(--edge); background: var(--surface-2);
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.04em; color: var(--ink-dim);
  white-space: nowrap;
}
.tag.role::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.tag.danger { border-color: rgba(255,90,90,0.4); color: var(--red); }
.tag.warn { border-color: rgba(249,236,49,0.35); color: var(--yellow); }
.tag.good { border-color: rgba(126,231,135,0.3); color: var(--green); }
.tag.owner { background: var(--yellow); border-color: var(--yellow); color: #14140b; font-weight: 700; }
.tag.bot { border-color: rgba(88,101,242,0.5); color: #8b93f8; }

.empty { padding: 40px 14px; text-align: center; color: var(--ink-faint); font-size: 13px; }
.loading { padding: 26px 14px; text-align: center; color: var(--ink-faint); font-family: var(--mono); font-size: 11.5px; }

.more { display: grid; place-items: center; margin-top: 14px; }

/* ── cards ──────────────────────────────────────────────────────────────── */

.card {
  padding: 15px 16px; margin-bottom: 12px;
  border: 1px solid var(--edge); border-radius: var(--radius-lg);
  background: var(--surface);
}
.card-label {
  margin: 0 0 10px; font-family: var(--mono); font-size: 10px;
  letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-faint);
}
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; }
.stat { padding: 11px 12px; border: 1px solid var(--edge); border-radius: var(--radius); background: var(--surface-2); }
.stat b { display: block; font-size: 20px; font-weight: 800; color: var(--yellow); line-height: 1.15; }
.stat span { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-faint); }

/* ── log entries ────────────────────────────────────────────────────────── */

.log { display: grid; gap: 4px; }
.log-entry {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: baseline;
  padding: 9px 12px; border: 1px solid var(--edge); border-radius: var(--radius);
  background: var(--surface); font-size: 13px;
}
.log-entry.bad { border-left: 2px solid var(--red); }
.log-entry.mine { border-left: 2px solid var(--yellow); }
.log-line { min-width: 0; }
.log-who { font-weight: 640; }
.log-verb { color: var(--ink-dim); }
.log-target { font-family: var(--mono); font-size: 12px; color: var(--cyan); }
.log-detail { margin-top: 3px; font-family: var(--mono); font-size: 11px; color: var(--ink-faint); word-break: break-word; }
.log-reason { margin-top: 3px; font-size: 12px; color: var(--ink-dim); font-style: italic; }
.log-time { font-family: var(--mono); font-size: 10.5px; color: var(--ink-faint); white-space: nowrap; }

.chips { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 14px; }
.chip {
  padding: 5px 12px; border: 1px solid var(--edge); border-radius: 100px;
  background: var(--surface); color: var(--ink-dim);
  font-family: var(--mono); font-size: 11px; cursor: pointer;
  transition: color 0.18s, border-color 0.18s;
}
.chip:hover { color: var(--ink); }
.chip[aria-pressed="true"] { border-color: var(--yellow); color: var(--yellow); }

/* ── dialogs ────────────────────────────────────────────────────────────── */

.sheet {
  width: min(660px, calc(100vw - 24px));
  max-height: min(86vh, 900px);
  padding: 18px 20px 20px;
  border: 1px solid var(--edge-hi); border-radius: var(--radius-lg);
  background: var(--surface); color: var(--ink);
  overflow-y: auto; overscroll-behavior: contain;
}
.sheet.small { width: min(420px, calc(100vw - 24px)); }
.sheet::backdrop { background: rgba(0, 0, 0, 0.72); backdrop-filter: blur(3px); }
.sheet-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.sheet-title { flex: 1; margin: 0; font-size: 17px; font-weight: 750; min-width: 0; }
.mfa-form { display: flex; gap: 8px; align-items: center; }
.mfa-form .code-input { flex: 1; min-width: 0; }

/* the member sheet */
.who { display: flex; align-items: center; gap: 13px; margin-bottom: 6px; min-width: 0; }
.who img { width: 52px; height: 52px; border-radius: 50%; background: var(--surface-3); flex-shrink: 0; }
.who-main { min-width: 0; flex: 1; }
.who-name { margin: 0; font-size: 18px; font-weight: 750; word-break: break-word; }
.who-id { font-family: var(--mono); font-size: 11px; color: var(--ink-faint); }
.who-tags { display: flex; gap: 5px; flex-wrap: wrap; margin: 10px 0 14px; }

.blocked-note {
  padding: 10px 12px; margin-bottom: 14px;
  border: 1px solid rgba(249,236,49,0.28); border-radius: var(--radius);
  background: rgba(249,236,49,0.06); color: var(--yellow); font-size: 12.5px;
}
.act-grid { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 14px; }
.facts { display: grid; gap: 6px; margin-bottom: 16px; }
.fact { display: flex; gap: 12px; font-size: 12.5px; }
.fact-key { width: 108px; flex-shrink: 0; font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-faint); padding-top: 1px; }
.fact-val { min-width: 0; word-break: break-word; }

.role-picker { display: flex; gap: 5px; flex-wrap: wrap; }
.role-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 11px; border: 1px solid var(--edge); border-radius: 100px;
  background: var(--surface-2); font-size: 12px; cursor: pointer;
  font-family: inherit; color: var(--ink-dim); transition: border-color 0.18s, color 0.18s;
}
.role-chip:hover:not(:disabled) { border-color: var(--edge-hi); color: var(--ink); }
.role-chip:disabled { opacity: 0.35; cursor: not-allowed; }
.role-chip[aria-pressed="true"] { border-color: currentColor; }
.role-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.role-chip.admin::after { content: "ADMIN"; font-family: var(--mono); font-size: 8.5px; letter-spacing: 0.08em; color: var(--red); }

.note { padding: 9px 11px; border: 1px solid var(--edge); border-left: 2px solid var(--cyan); border-radius: var(--radius); background: var(--surface-2); margin-bottom: 6px; }
.note-body { font-size: 13px; white-space: pre-wrap; word-break: break-word; }
.note-meta { margin-top: 4px; font-family: var(--mono); font-size: 10px; color: var(--ink-faint); display: flex; gap: 8px; align-items: center; }
.note-meta button { margin-left: auto; background: none; border: none; color: var(--ink-faint); cursor: pointer; font-family: inherit; font-size: 10px; }
.note-meta button:hover { color: var(--red); }

/* ── toasts ─────────────────────────────────────────────────────────────── */

.toasts {
  position: fixed; inset: auto 0 20px 0; z-index: 90;
  display: grid; gap: 8px; justify-items: center;
  border: none; background: none; padding: 0; margin: 0; overflow: visible; width: 100%;
}
.toasts:not(:popover-open) { display: none; }
.toast {
  padding: 10px 16px; border: 1px solid var(--edge-hi); border-radius: var(--radius);
  background: var(--surface-3); color: var(--ink);
  font-size: 13px; box-shadow: 0 14px 34px -14px #000;
  max-width: min(520px, calc(100vw - 32px));
  animation: rise 0.25s var(--ease);
}
.toast.good { border-color: rgba(126,231,135,0.4); }
.toast.bad { border-color: rgba(255,90,90,0.5); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ── narrow screens ─────────────────────────────────────────────────────── */

@media (max-width: 720px) {
  .topbar { height: auto; flex-wrap: wrap; padding-top: 9px; padding-bottom: 9px; gap: 9px; }
  .tabs { order: 3; flex-basis: 100%; margin: 0 calc(-1 * clamp(14px, 3vw, 26px)); padding: 0 clamp(14px, 3vw, 26px); }
  .guild-chip { max-width: 130px; }
  .row { flex-wrap: wrap; }
  .row-tags { flex-basis: 100%; justify-content: flex-start; }
  .log-entry { grid-template-columns: minmax(0, 1fr); }
  .log-time { grid-row: 1; justify-self: start; }
  .fact { flex-direction: column; gap: 1px; }
  .fact-key { width: auto; }
  .sheet { width: 100vw; max-width: 100vw; max-height: 92vh; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
  .act-grid .btn { flex: 1; }
}

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