*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg:      #000;
  --text:    #fff;
  --muted:   #444;
  --dim:     #222;
  --surface: rgba(0, 0, 0, 0.94);
}

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: monospace;
}

/* ── CANVAS ───────────────────────────────────────────────── */
canvas {
  position: fixed;
  top: 40px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100vw - 4rem);
  max-width: 1200px;
  height: calc(100vh - 80px);
  height: calc(100dvh - 80px);
  display: block;
  border: 2px solid var(--text);
  border-radius: 4px;
}

/* ── NAV ──────────────────────────────────────────────────── */
nav {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 40px;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 2rem;
  padding: 0 max(2rem, calc((100vw - 1200px) / 2));
  background: var(--surface);
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  user-select: none;
  text-decoration: none;
  color: var(--text);
}

.logo-mark {
  display: flex;
  align-items: center;
  height: 100%;
  overflow: hidden;
}

.logo-mark img {
  display: block;
  height: 26px;
  width: auto;
  filter: brightness(0) invert(1);
  object-fit: contain;
}

.logo-text {
  font-size: 0.95rem;
  font-weight: bold;
  letter-spacing: 0.08em;
}

.nav-links {
  list-style: none;
  display: flex;
  gap: 2rem;
}

.nav-links a {
  color: var(--text);
  text-decoration: none;
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  cursor: pointer;
  border-radius: 3px;
  border: 1px solid transparent;
  padding: 0.15rem 0.4rem;
  transition: border-color 0.15s;
}

.nav-links a:hover,
.nav-links a.active {
  border-color: var(--text);
}

/* ── FOOTER ───────────────────────────────────────────────── */
footer {
  position: fixed;
  bottom: 0; left: 0;
  width: 100%; height: 40px;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3rem;
  padding: 0 max(2rem, calc((100vw - 1200px) / 2));
  background: var(--surface);
}

footer a {
  color: var(--text);
  text-decoration: none;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  cursor: pointer;
  border-radius: 4px;
  border: 1px solid transparent;
  padding: 0.15rem 0.4rem;
  transition: border-color 0.15s;
}

footer a:hover,
footer a.active {
  border-color: var(--text);
}

/* ── BACKDROP ─────────────────────────────────────────────── */
.backdrop { display: none; }
.backdrop.open { display: block; }

/* ── MODAL ────────────────────────────────────────────────── */
.modal {
  position: fixed;
  top: 20%;
  left: 20%;
  transform: translate(-20%, -20%);
  z-index: 200;
  background: #000;
  border: 2px solid var(--text);
  border-radius: 4px;
  width: min(90vw, 460px);
  overflow: hidden;
}

.modal-titlebar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.75rem;
  border-bottom: 2px solid var(--text);
  background: #000;
}

.modal-titlebar span {
  font-size: 0.72rem;
  color: var(--text);
  letter-spacing: 0.06em;
}

.modal-close {
  border: 1px solid var(--text);
  border-radius: 2px;
  background: none;
  color: var(--text);
  font-size: 0.72rem;
  font-family: monospace;
  cursor: pointer;
  padding: 0.1rem 0.5rem;
  letter-spacing: 0.05em;
  transition: background 0.15s, color 0.15s;
  line-height: 1.5;
}

.modal-close:hover {
  background: var(--text);
  color: var(--bg);
}

.modal-body {
  padding: 1.5rem 1.75rem 2rem;
  max-height: calc(80dvh - 60px);
  overflow-y: auto;
}

.modal h2 {
  font-size: 0.8rem;
  font-weight: bold;
  letter-spacing: 0.14em;
  margin-bottom: 1rem;
  color: var(--text);
}




.modal p {
  color: #888;
  font-size: 0.72rem;
  line-height: 1.85;
  margin-bottom: 0.5rem;
}

.modal p:last-child { margin-bottom: 0; }
.modal p strong { color: var(--text); }
.modal a { color: var(--text); }

/* ── ASCII MODAL ───────────────────────────────────────────────── */
.modal-ascii {
  font-family: monospace;
  font-size: 0.7rem;
  line-height: 1.5;
  white-space: pre;
  color: var(--muted);
  overflow-x: auto;
  margin: 0;
}

.modal-ascii .hi  { color: var(--text); }
.modal-ascii .dim { color: var(--dim);  }

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}
.blink { animation: blink 1.1s step-end infinite; }

/* ── TREE (trans-csm modal) ────────────────────────────────────── */
.tree { line-height: 2; font-size: 0.72rem; }

.tl {
  display: flex;
  align-items: baseline;
  white-space: nowrap;
  overflow: hidden;
  opacity: 0;
  transform: translateY(4px);
  transition: color 0.1s;
}
.tl.visible { animation: tl-in 0.01s step-end forwards; }
@keyframes tl-in { to { opacity: 1; transform: none; } }

.tl.spacer { cursor: default; }
.tl.parent { cursor: pointer; }
.tl.leaf   { cursor: default; }

.br     { color: #222; flex-shrink: 0; white-space: pre; }
.toggle { color: #444; margin-right: 1ch; flex-shrink: 0; transition: color 0.15s; }

@media (hover: hover) {
  .tl.parent:hover .nn { color: #bbb; }
  .tl.parent:hover .toggle { color: #888; }
}

.nn            { flex: 1; overflow: hidden; text-overflow: ellipsis; transition: color 0.12s; }
.nn.root       { color: var(--text); font-size: 0.8rem; }
.nn.cat        { color: var(--text); font-size: 0.8rem; }
.nn.sub        { color: #888; }
.nn.dim        { color: #1e1e1e; }

.tl-right {
  flex-shrink: 0;
  margin-left: 1.5ch;
  font-size: 0.65rem;
  font-family: monospace;
  padding: 0.05rem 0.7rem;
  border-radius: 2px;
  border: 1px solid;
  letter-spacing: 0.15em;
  transition: color 0.12s, border-color 0.12s;
}
.tl-right.is-open   { color: #444; border-color: #444; }
.tl-right.is-closed { color: #aaa; border-color: #aaa; }

.children {
  overflow: hidden;
  max-height: 2000px;
  transition: max-height 0.35s cubic-bezier(0.4,0,0.2,1), opacity 0.25s ease;
  opacity: 1;
}
.children.collapsed { max-height: 0; opacity: 0; }

/* ── CONTACT FORM ─────────────────────────────────────────── */
.modal-body form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.1rem;
}

.modal input,
.modal textarea {
  background: #000;
  border: 1px solid #3a3a3a;
  border-radius: 4px;
  padding: 0.55rem 0.75rem;
  color: var(--text);
  font-size: 16px;
  font-family: monospace;
  outline: none;
  resize: none;
  transition: border-color 0.15s;
}

.modal input::placeholder,
.modal textarea::placeholder { color: #555; font-size: 0.82rem; }

.modal input:focus,
.modal textarea:focus { border-color: #666; }

.modal textarea { min-height: 100px; }

.modal .btn-send {
  background: var(--text);
  border: 1px solid var(--text);
  border-radius: 4px;
  padding: 0.6rem;
  color: #000;
  font-size: 0.8rem;
  font-weight: bold;
  font-family: monospace;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  margin-top: 0.25rem;
}

.modal .btn-send:hover {
  background: #000;
  color: var(--text);
}
