/* F8Sec Library — brand-themed: deep navy + gold accent + violet/teal/red signals.
   No external fonts; no external assets beyond /assets/logo.gif. */

:root {
  --bg: #07080d;
  --bg2: #0c1018;
  --line: #1a2030;
  --line2: #283145;
  --text: #eef2fa;
  --muted: #8995a8;
  --muted2: #5e6b80;
  --gold: #ce991c;
  --teal: #38bdf8;
  --green: #22c55e;
  --violet: #a855f7;
  --red: #ff7a85;
  --mono: 'JetBrains Mono','Fira Code',ui-monospace,monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
.lib-body {
  background: radial-gradient(ellipse at top, #0a1018 0%, var(--bg) 80%);
  color: var(--text);
  font-family: var(--mono);
  min-height: 100vh;
  overflow-x: hidden;
}

/* (Hero / full-screen entry animation removed 2026-04-29 — too heavy.
    Library now renders directly. Small lib-mark logo stays in the header.) */

/* ── Top bar ────────────────────────────────────────────────────────── */
.library {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  opacity: 0;
  animation: lib-in 600ms ease 100ms forwards;
}
@keyframes lib-in { to { opacity: 1; } }

.lib-top {
  display: flex;
  align-items: center;
  gap: 1.2rem;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(8,12,28,0.92), rgba(8,12,28,0.7));
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 20;
}

/* Logo top-left, color-cycling pulse border */
.lib-mark {
  display: inline-flex;
  position: relative;
  width: 56px; height: 56px;
  flex-shrink: 0;
}
.lib-mark .lib-pulse {
  position: relative;
  display: inline-block;
  width: 56px; height: 56px;
  border-radius: 12px;
  padding: 3px;
  background: conic-gradient(from 0deg,
    var(--gold), var(--teal), var(--violet), var(--green), var(--red), var(--gold));
  animation: pulse-rotate 8s linear infinite;
}
.lib-mark .lib-pulse::after {
  content: "";
  position: absolute; inset: 0;
  border-radius: 12px;
  background: conic-gradient(from 0deg,
    var(--gold), var(--teal), var(--violet), var(--green), var(--red), var(--gold));
  filter: blur(14px);
  opacity: 0.55;
  z-index: -1;
  animation: pulse-rotate 8s linear infinite reverse, pulse-breathe 3.6s ease-in-out infinite;
}
.lib-mark-img {
  width: 100%; height: 100%;
  border-radius: 9px;
  background: var(--bg2);
  display: block;
  object-fit: cover;
}
@keyframes pulse-rotate { to { transform: rotate(360deg); } }
@keyframes pulse-breathe { 50% { opacity: 0.85; filter: blur(20px); } }

/* Quote ticker */
.lib-quote {
  flex: 1;
  min-width: 0;
  display: flex; flex-direction: column;
  gap: 2px;
  padding: 0 6px;
}
.lib-quote-text {
  color: var(--text);
  font-size: 0.8rem;
  font-style: italic;
  letter-spacing: 0.2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  opacity: 0;
  transition: opacity 600ms ease;
}
.lib-quote-text.show { opacity: 0.92; }
.lib-quote-attr {
  color: var(--muted);
  font-size: 0.62rem;
  letter-spacing: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  opacity: 0;
  transition: opacity 600ms ease;
}
.lib-quote-attr.show { opacity: 0.7; }
.lib-quote-attr::before { content: "— "; color: var(--gold); }

.lib-stats {
  font-size: 0.62rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted);
  flex-shrink: 0;
}
.lib-stats b { color: var(--gold); font-weight: 700; }

/* ── Tree ───────────────────────────────────────────────────────────── */
.lib-tree-wrap {
  flex: 1;
  display: flex;
  position: relative;
  overflow: hidden;
}

#lib-tree {
  flex: 1;
  width: 100%;
  height: 100%;
  cursor: grab;
  user-select: none;
}
#lib-tree:active { cursor: grabbing; }

#lib-tree .tree-link {
  fill: none;
  stroke: var(--line2);
  stroke-width: 1.2;
  stroke-dasharray: 1 3;
  opacity: 0.7;
}

#lib-tree .tree-node circle {
  fill: var(--bg2);
  stroke: var(--gold);
  stroke-width: 1.6;
  transition: fill 0.15s, stroke 0.15s, r 0.2s;
}
#lib-tree .tree-node:hover circle { fill: rgba(206,153,28,0.18); }
#lib-tree .tree-node.open > circle { fill: var(--gold); stroke: #fff5d4; }
#lib-tree .tree-node.has-children > circle { stroke-width: 2.2; }
#lib-tree .tree-node.leaf > circle { stroke: var(--teal); }
#lib-tree .tree-node.leaf.partial > circle { stroke: var(--gold); stroke-dasharray: 2 2; }
#lib-tree .tree-node.root > circle { stroke: var(--violet); stroke-width: 2; r: 5; }

#lib-tree .tree-label {
  fill: var(--text);
  font-family: var(--mono);
  font-size: 11px;
  pointer-events: none;
}
#lib-tree .tree-node.root .tree-label { fill: var(--violet); font-size: 12px; letter-spacing: 1.5px; }
#lib-tree .tree-node.portal .tree-label { fill: var(--gold); letter-spacing: 1px; }
#lib-tree .tree-node.category .tree-label { fill: #c8d3e6; }
#lib-tree .tree-node.leaf .tree-label { fill: var(--muted); font-size: 10.5px; }

#lib-tree .tree-actions text {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
}
#lib-tree .tree-actions .act-t { fill: var(--teal); }
#lib-tree .tree-actions .act-l { fill: var(--gold); }
#lib-tree .tree-actions text:hover { filter: brightness(1.4); }

/* Leaf side panel */
.leaf-panel {
  position: absolute;
  top: 12px; right: 12px; bottom: 12px;
  width: min(380px, 36vw);
  background: rgba(8,12,28,0.96);
  border: 1px solid var(--line2);
  border-radius: 10px;
  padding: 16px;
  box-shadow: -8px 8px 30px rgba(0,0,0,0.5);
  display: none;
  flex-direction: column;
  gap: 8px;
  font-size: 0.78rem;
  overflow-y: auto;
}
.leaf-panel.open { display: flex; }
.leaf-panel h3 { color: var(--gold); font-size: 0.78rem; letter-spacing: 1.5px; text-transform: uppercase; }
.leaf-panel .meta { color: var(--muted); font-size: 0.66rem; }
.leaf-panel .summary { color: var(--text); font-size: 0.74rem; line-height: 1.6; padding: 8px 10px; background: rgba(255,255,255,0.025); border-radius: 6px; }
.leaf-panel .partial-warn { color: var(--gold); font-size: 0.65rem; }
.leaf-panel .actions { display: flex; gap: 8px; margin-top: 8px; }
.leaf-panel .actions button {
  padding: 7px 14px;
  border-radius: 6px;
  border: 1px solid var(--line2);
  background: var(--bg2);
  color: var(--text);
  font-family: var(--mono); font-size: 0.7rem; letter-spacing: 1.5px;
  cursor: pointer; transition: all 0.15s;
}
.leaf-panel .actions .act-t { color: var(--teal); border-color: rgba(56,189,248,0.4); }
.leaf-panel .actions .act-t:hover { background: rgba(56,189,248,0.12); }
.leaf-panel .actions .act-l { color: var(--gold); border-color: rgba(206,153,28,0.4); }
.leaf-panel .actions .act-l:hover { background: rgba(206,153,28,0.12); }
.leaf-panel .panel-close {
  position: absolute; top: 6px; right: 8px;
  background: transparent; border: none; color: var(--muted);
  font-size: 1.1rem; cursor: pointer;
}

#replay-host {
  flex: 1;
  margin-top: 8px;
  background: rgba(0,0,0,0.5);
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow-y: auto;
  padding: 8px 10px;
  font-size: 0.65rem;
  display: flex; flex-direction: column; gap: 2px;
  font-family: var(--mono);
}
#replay-host .ev { display: flex; gap: 6px; }
#replay-host .ts { color: var(--muted2); flex-shrink: 0; }
#replay-host .who { font-weight: 700; flex-shrink: 0; }
#replay-host .who.admin { color: var(--gold); }
#replay-host .who.system { color: var(--teal); }
#replay-host .who.engage { color: var(--green); }
#replay-host .txt { color: var(--text); word-break: break-word; }

/* ── Footer / hints ─────────────────────────────────────────────────── */
.lib-foot {
  display: flex;
  gap: 1.2rem;
  justify-content: center;
  padding: 8px 14px;
  border-top: 1px solid var(--line);
  font-size: 0.6rem;
  color: var(--muted2);
}
.lib-foot b { color: var(--gold); font-weight: 700; }
.lib-foot .lib-key + .lib-key::before { content: "·"; color: var(--line2); margin-right: 1.2rem; }

/* ── Auth modal — minimalist (no labels, no length, no format hints) ── */
.auth-modal {
  position: fixed; inset: 0;
  background: rgba(3,6,12,0.85);
  backdrop-filter: blur(10px);
  display: flex; align-items: center; justify-content: center;
  z-index: 300;
}
/* Honor the [hidden] attribute — class rules above outrank UA-stylesheet
   [hidden]:display:none on specificity, so we restate it explicitly here.
   Without this, the auth modal renders permanently and covers the tree.  */
.auth-modal[hidden] { display: none !important; }
.auth-card {
  position: relative;
  width: min(320px, 90vw);
  padding: 1.6rem 1.4rem 1.2rem;
  background: rgba(8,12,28,0.95);
  border: 1px solid var(--line2);
  border-radius: 10px;
  display: flex; flex-direction: column; gap: 0.7rem;
}
.auth-card h2 {
  color: var(--gold);
  font-size: 0.7rem;
  letter-spacing: 4px;
  text-transform: uppercase;
  text-align: center;
  margin-bottom: 0.2rem;
}
.auth-card input {
  width: 100%;
  padding: 9px 12px;
  background: rgba(0,0,0,0.4);
  border: 1px solid var(--line2);
  border-radius: 5px;
  color: var(--text);
  font: 0.85rem var(--mono);
  letter-spacing: 1.2px;
  text-align: center;
}
.auth-card input:focus { outline: none; border-color: var(--gold); }
.auth-card button[type="submit"] {
  margin-top: 0.4rem;
  padding: 8px;
  background: var(--gold);
  border: none;
  border-radius: 5px;
  color: #0a0a0a;
  font-weight: 700;
  font-size: 0.7rem;
  letter-spacing: 2px;
  cursor: pointer;
}
.auth-card .auth-err {
  min-height: 1rem;
  color: var(--red);
  font-size: 0.62rem;
  text-align: center;
  letter-spacing: 0.5px;
}
.auth-card .auth-close {
  position: absolute; top: 4px; right: 8px;
  background: transparent; border: none; color: var(--muted);
  font-size: 1.4rem; cursor: pointer;
}

/* ── Auth tabs (Admin PIN | Slot Login) — mirror sift/pen pattern ── */
.auth-card .auth-tabs {
  display: flex; gap: 0; margin: 0.2rem 0 0.6rem; border-bottom: 1px solid var(--line2);
}
.auth-card .auth-tab {
  flex: 1; padding: 8px 6px; background: transparent; border: none;
  color: var(--muted); font: 0.6rem var(--mono); letter-spacing: 1.5px;
  text-transform: uppercase; cursor: pointer; border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s;
}
.auth-card .auth-tab:hover { color: var(--text); }
.auth-card .auth-tab.active { color: var(--gold); border-bottom-color: var(--gold); }
.auth-card .auth-pane { display: none; flex-direction: column; gap: 0.6rem; }
.auth-card .auth-pane.active { display: flex; }
.auth-card .auth-pane form { display: flex; flex-direction: column; gap: 0.6rem; }
/* Architect principal field — prefilled, blurred until focus */
.auth-card input.blurred {
  filter: blur(4px); user-select: none; -webkit-user-select: none;
  transition: filter .25s ease;
}
.auth-card input.blurred:focus { filter: blur(0); }
