:root {
  --bg: #020a04;
  --pip: #3dff7a;
  --pip-rgb: 61, 255, 122;
  --font: 'Share Tech Mono', ui-monospace, Consolas, monospace;
  --font-big: 'VT323', 'Share Tech Mono', ui-monospace, monospace;
}
body[data-theme="amber"] { --bg: #0b0600; --pip: #ffb642; --pip-rgb: 255, 182, 66; }
body[data-theme="blue"]  { --bg: #00070b; --pip: #2ecfff; --pip-rgb: 46, 207, 255; }
body[data-theme="white"] { --bg: #05070a; --pip: #dfefff; --pip-rgb: 223, 239, 255; }

:root, body {
  --dim: rgba(var(--pip-rgb), .55);
  --faint: rgba(var(--pip-rgb), .22);
  --ghost: rgba(var(--pip-rgb), .08);
  --glow: 0 0 2px rgba(var(--pip-rgb), .9), 0 0 9px rgba(var(--pip-rgb), .45);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: #000;
  color: var(--pip);
  font-family: var(--font);
  font-size: 15px;
  overflow: hidden;
}
button, input { font: inherit; color: inherit; }
::selection { background: var(--pip); color: var(--bg); }

/* ---------- CRT ---------- */
.crt {
  height: 100%;
  padding: 14px;
  background: radial-gradient(ellipse at center, #111 0%, #000 75%);
}
.screen {
  position: relative;
  height: 100%;
  display: flex;
  flex-direction: column;
  border-radius: 18px;
  background: radial-gradient(ellipse at 50% 45%, rgba(var(--pip-rgb), .10) 0%, var(--bg) 70%), var(--bg);
  box-shadow: inset 0 0 80px rgba(0, 0, 0, .9), inset 0 0 18px rgba(var(--pip-rgb), .18), 0 0 0 2px #151a16, 0 0 40px rgba(var(--pip-rgb), .08);
  text-shadow: var(--glow);
  overflow: hidden;
  padding: 18px 26px 12px;
  animation: flicker 6s infinite steps(1);
}
.screen::before { /* scanlines */
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 50;
  background: repeating-linear-gradient(to bottom, rgba(0, 0, 0, .28) 0 1px, transparent 1px 3px);
}
.screen::after { /* rollende scanbalk + vignet */
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 51;
  background:
    linear-gradient(to bottom, transparent 0%, rgba(var(--pip-rgb), .05) 50%, transparent 100%) 0 -100% / 100% 30% no-repeat,
    radial-gradient(ellipse at center, transparent 60%, rgba(0, 0, 0, .55) 100%);
  animation: roll 7s linear infinite;
}
@keyframes roll { to { background-position: 0 230%, 0 0; } }
@keyframes flicker { 0%, 100% { opacity: 1; } 47% { opacity: .96; } 48% { opacity: 1; } 83% { opacity: .98; } }
@media (prefers-reduced-motion: reduce) { .screen, .screen::after { animation: none; } }

/* ---------- boot ---------- */
.boot {
  position: absolute; inset: 0; z-index: 40; background: var(--bg);
  padding: 28px 34px; display: none; cursor: pointer;
}
.boot.on { display: block; }
.boot pre { margin: 0; font-family: var(--font); white-space: pre-wrap; line-height: 1.45; }

/* ---------- header / tabs ---------- */
.top { flex: none; }
.tabs { display: flex; justify-content: center; gap: clamp(10px, 5vw, 70px); }
.tab {
  background: none; border: 0; cursor: pointer; padding: 2px 10px 6px;
  font-family: var(--font-big); font-size: 30px; letter-spacing: 2px; color: var(--dim);
  text-shadow: none; position: relative;
}
.tab .k { font-size: 13px; font-family: var(--font); margin-right: 6px; vertical-align: 6px; opacity: .6; }
.tab:hover { color: var(--pip); }
.tab.active { color: var(--pip); text-shadow: var(--glow); }
/* actieve tab: lijn buigt omhoog om de tab heen (┘ INV └) */
.tab.active::after {
  content: ""; position: absolute; left: -8px; right: -8px; top: 45%; bottom: -3px; z-index: 2;
  border-left: 2px solid var(--pip); border-right: 2px solid var(--pip);
  background: linear-gradient(to bottom, transparent calc(100% - 5px), var(--bg) calc(100% - 5px));
  box-shadow: -1px 0 4px -2px rgba(var(--pip-rgb), .6), 1px 0 4px -2px rgba(var(--pip-rgb), .6);
}
.topline { height: 2px; background: var(--pip); box-shadow: 0 0 6px rgba(var(--pip-rgb), .6); }

/* ---------- views ---------- */
.view { display: none; flex: 1; min-height: 0; min-width: 0; flex-direction: column; padding-top: 12px; }
.view.active { display: flex; }

.subtabs-wrap { display: flex; align-items: center; gap: 10px; flex: none; }
.hint { color: var(--dim); font-size: 13px; text-shadow: none; white-space: nowrap; }
.subtabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; flex: 1; min-width: 0; }
.subtabs::-webkit-scrollbar { display: none; }
.subtab {
  background: none; border: 0; cursor: pointer; white-space: nowrap; padding: 3px 10px;
  color: var(--dim); text-shadow: none; text-transform: uppercase; letter-spacing: 1px;
}
.subtab:hover { color: var(--pip); }
.subtab.active { color: var(--pip); text-shadow: var(--glow); border-bottom: 2px solid var(--pip); }
.subtab .n { opacity: .6; margin-left: 4px; font-size: 12px; }

.searchbar { display: flex; align-items: center; gap: 8px; margin: 10px 0 8px; flex: none; }
.searchbar label { letter-spacing: 1px; }
.searchbar input {
  flex: 1; background: var(--ghost); border: 1px solid var(--faint); padding: 5px 8px; outline: none;
  caret-color: var(--pip); text-shadow: var(--glow); min-width: 0;
}
.searchbar input:focus { border-color: var(--pip); }
.searchbar input::placeholder { color: var(--faint); text-shadow: none; }
.count { color: var(--dim); font-size: 13px; white-space: nowrap; }

/* ---------- INV ---------- */
.inv { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(260px, 38%) minmax(0, 1fr); gap: 22px; }
.list {
  list-style: none; margin: 0; padding: 0 6px 0 0; overflow-y: auto; min-height: 0;
  scrollbar-width: thin; scrollbar-color: var(--dim) transparent;
}
.list li {
  display: flex; align-items: center; gap: 8px; padding: 4px 8px; cursor: pointer;
  border: 1px solid transparent; white-space: nowrap;
}
.list li .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.list li .badge { font-size: 12px; opacity: .75; }
.list li .new { font-size: 11px; padding: 0 4px; border: 1px solid currentColor; }
.list li:hover { border-color: var(--faint); }
.list li.sel { background: var(--pip); color: var(--bg); text-shadow: none; box-shadow: 0 0 10px rgba(var(--pip-rgb), .5); }
.list li.arch .nm { opacity: .6; }
.list li.flash { animation: flash .35s 6 steps(1); }
@keyframes flash { 50% { background: var(--pip); color: var(--bg); } }
.list .group { padding: 10px 8px 3px; color: var(--dim); font-size: 12px; letter-spacing: 2px; cursor: default; text-shadow: none; }
.list .group:hover { border-color: transparent; }
.empty { color: var(--dim); padding: 20px 8px; text-shadow: none; }

.detail { overflow-y: auto; min-height: 0; padding-right: 8px; scrollbar-width: thin; scrollbar-color: var(--dim) transparent; }
.d-head { display: flex; gap: 16px; align-items: center; margin-bottom: 12px; }
.d-icon {
  width: 72px; height: 72px; flex: none; border: 2px solid var(--pip); display: grid; place-items: center;
  box-shadow: 0 0 8px rgba(var(--pip-rgb), .4), inset 0 0 12px rgba(var(--pip-rgb), .2);
}
.d-icon img { width: 56px; height: 56px; object-fit: contain; filter: grayscale(1) brightness(1.2) sepia(1) hue-rotate(var(--hue, 70deg)) saturate(4); }
body[data-theme="amber"] .d-icon img { --hue: -15deg; }
body[data-theme="blue"] .d-icon img { --hue: 150deg; }
body[data-theme="white"] .d-icon img { filter: grayscale(1) brightness(1.4); }
.d-icon svg { width: 46px; height: 46px; }
.d-title { font-family: var(--font-big); font-size: 34px; line-height: 1; word-break: break-word; }
.d-path { color: var(--dim); font-size: 13px; text-shadow: none; margin-top: 4px; word-break: break-all; }
.d-syn { margin: 0 0 14px; line-height: 1.45; }

.stats { margin: 0 0 14px; padding: 0; border-top: 1px solid var(--faint); }
.stats div { display: flex; justify-content: space-between; gap: 12px; padding: 4px 6px; border-bottom: 1px solid var(--faint); }
.stats div:nth-child(odd) { background: var(--ghost); }
.stats dt { color: var(--dim); letter-spacing: 1px; text-shadow: none; }
.stats dd { margin: 0; text-align: right; word-break: break-word; }

.warn {
  border: 2px dashed var(--pip); padding: 8px 12px; margin: 0 0 14px; line-height: 1.45;
  animation: warnblink 1.6s infinite steps(1);
}
.warn b { display: block; letter-spacing: 2px; margin-bottom: 4px; }
.warn .sub { color: var(--dim); text-shadow: none; margin-top: 6px; font-size: 13px; }
@keyframes warnblink { 50% { border-color: var(--faint); } }
@media (prefers-reduced-motion: reduce) { .warn { animation: none; } }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.tag { border: 1px solid var(--pip); padding: 1px 7px; font-size: 12px; letter-spacing: 1px; }
.tag.solid { background: var(--pip); color: var(--bg); text-shadow: none; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.btn {
  background: transparent; border: 1px solid var(--pip); padding: 6px 12px; cursor: pointer;
  letter-spacing: 1px; text-decoration: none; color: var(--pip); text-shadow: var(--glow); display: inline-block;
}
.btn:hover, .btn:focus-visible { background: var(--pip); color: var(--bg); text-shadow: none; outline: none; }
.btn-ghost { background: none; border: 0; cursor: pointer; padding: 0; text-shadow: inherit; }
.btn-ghost:hover { text-decoration: underline; }

.d-sec h4 { margin: 0 0 6px; font-weight: normal; letter-spacing: 2px; color: var(--dim); text-shadow: none; }
.d-sec { margin-bottom: 16px; }
.d-sec pre { margin: 0; white-space: pre-wrap; font-family: var(--font); line-height: 1.45; font-size: 14px; }
.d-sec pre.ex { background: var(--ghost); border-left: 2px solid var(--pip); padding: 6px 10px; margin-bottom: 6px; }

/* ---------- panels / STAT / DATA / MAP ---------- */
.panel { border: 1px solid var(--faint); padding: 12px 14px; min-height: 0; overflow: auto; scrollbar-width: thin; scrollbar-color: var(--dim) transparent; }
.panel h3 { margin: 0 0 10px; font-weight: normal; letter-spacing: 3px; font-size: 14px; color: var(--dim); text-shadow: none; }
.grow { flex: 1; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 14px; flex: none; }
.stat-box { border: 1px solid var(--pip); padding: 10px 12px; box-shadow: inset 0 0 14px rgba(var(--pip-rgb), .12); }
.stat-box .v { font-family: var(--font-big); font-size: 46px; line-height: 1; }
.stat-box .l { color: var(--dim); letter-spacing: 2px; font-size: 12px; text-shadow: none; }
.stat-cols, .data-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; flex: 1; min-height: 0; }
.bar { display: grid; grid-template-columns: minmax(90px, 34%) 1fr 34px; gap: 10px; align-items: center; padding: 3px 0; cursor: pointer; }
.bar:hover .bl { text-decoration: underline; }
.bar .bl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-transform: uppercase; font-size: 13px; }
.bar .bt { height: 12px; background: repeating-linear-gradient(90deg, var(--pip) 0 7px, transparent 7px 9px); box-shadow: 0 0 6px rgba(var(--pip-rgb), .4); }
.bar .bn { text-align: right; }
.log { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.log li { padding: 4px 0; border-bottom: 1px dashed var(--faint); display: flex; gap: 10px; cursor: pointer; }
.log li:hover { background: var(--ghost); }
.log .t { color: var(--dim); white-space: nowrap; text-shadow: none; }
.log .what { white-space: nowrap; min-width: 92px; }
.log .p { word-break: break-all; }
.tree { margin: 0; font-family: var(--font); line-height: 1.5; font-size: 14px; }
.tree a { color: inherit; text-decoration: none; cursor: pointer; }
.tree a:hover { background: var(--pip); color: var(--bg); text-shadow: none; }
.tree .dir { color: var(--dim); }
#view-map { overflow: hidden; }
#view-map .panel { display: block; }

/* ---------- footer ---------- */
.bottom { flex: none; display: flex; gap: 6px; margin-top: 10px; font-size: 14px; }
.bottom .cell { background: rgba(var(--pip-rgb), .16); padding: 4px 10px; white-space: nowrap; display: flex; align-items: center; gap: 8px; }
.bottom .grow { overflow: hidden; text-overflow: ellipsis; }
.live { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.live.on { background: var(--pip); box-shadow: 0 0 8px var(--pip); animation: pulse 2s infinite; }
@keyframes pulse { 50% { opacity: .35; } }

/* ---------- toast ---------- */
.toast {
  position: absolute; right: 26px; bottom: 54px; z-index: 30; max-width: min(460px, 80%);
  border: 2px solid var(--pip); background: var(--bg); padding: 10px 14px; display: none;
  box-shadow: 0 0 16px rgba(var(--pip-rgb), .4);
}
.toast.on { display: block; }
.toast b { display: block; letter-spacing: 2px; margin-bottom: 3px; }

/* ---------- modal / bronviewer ---------- */
.modal { position: fixed; inset: 0; z-index: 100; background: rgba(0, 0, 0, .75); padding: 28px; display: flex; }
.modal[hidden] { display: none; }
.modal-box { height: 100%; width: 100%; padding: 14px 18px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding-bottom: 10px; border-bottom: 2px solid var(--pip); flex: none; }
.modal-head span { font-family: var(--font-big); font-size: 26px; word-break: break-all; }
.modal-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.code { flex: 1; min-height: 0; overflow: auto; display: flex; margin-top: 10px; scrollbar-width: thin; scrollbar-color: var(--dim) transparent; }
.code pre { margin: 0; font-family: Consolas, var(--font); font-size: 13px; line-height: 1.5; }
.gutter { color: var(--faint); text-align: right; padding-right: 12px; border-right: 1px solid var(--faint); user-select: none; text-shadow: none; position: sticky; left: 0; background: var(--bg); }
.src { padding-left: 12px; tab-size: 4; }
.src .c { opacity: .5; font-style: italic; }
.src .s { opacity: .8; }
.src .v { font-weight: bold; }
.src .kw { text-decoration: underline; text-decoration-color: var(--faint); text-underline-offset: 3px; }
.src .cm { background: var(--ghost); }

/* ---------- mobiel ---------- */
@media (max-width: 760px) {
  body { overflow-x: hidden; overflow-y: auto; font-size: 14px; }
  .crt { padding: 0; height: auto; min-height: 100%; }
  .screen { border-radius: 0; padding: 12px 16px; min-height: 100vh; height: auto; max-width: 100vw; }
  .tabs { gap: 6px; justify-content: space-between; }
  .tab { font-size: 22px; padding: 2px 4px 6px; }
  .tab .k { display: none; }
  .hint { display: none; }
  .inv, .stat-cols, .data-cols { grid-template-columns: minmax(0, 1fr); }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-box .v { font-size: 34px; }
  .detail { overflow: visible; }
  .bottom .grow { flex-basis: 100%; order: 5; }
  .list { max-height: 45vh; }
  .bottom { flex-wrap: wrap; }
  .modal { padding: 0; }
}
