:root {
  --bg: #000;
  --fg: #e627ff; /* phosphor green */
  --fg-dim: #38ff92;
  --accent: #00ffea;
  --danger: #ff4d4d;
  --link: #8be9fd;
  --shadow: rgba(0, 255, 170, 0.1);
}

/* Basic reset */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  line-height: 1.5; text-rendering: optimizeLegibility; image-rendering: pixelated;
}

/* CRT scanline + vignette effect (turned off for prefers-reduced-motion) */
body::before, body::after {
  content: ""; position: fixed; inset: 0; pointer-events: none;
}
body::before { /* scanlines */
  background: repeating-linear-gradient( to bottom, rgba(0,0,0,.0) 0px, rgba(0,0,0,.0) 2px, rgba(0,0,0,.12) 3px );
  mix-blend-mode: multiply; opacity: .35; z-index: 1;
}
body::after { /* vignette */
  box-shadow: inset 0 0 120px 40px rgba(0,0,0,.8); z-index: 1;
}

.skip-link {
  position: absolute; left: -999px; top: 0; background: #111; color: #fff; padding: .5rem .75rem; 
  border: 1px dashed var(--fg); text-decoration: none; z-index: 10000;
}
.skip-link:focus { left: .5rem; top: .5rem; outline: 2px solid var(--accent); }

.grid {
  display: grid; grid-template-columns: 240px 1fr; gap: 0; min-height: 100vh; position: relative;
}

header {
  grid-column: 1 / -1; position: relative; padding: .75rem 1rem; border-bottom: 1px solid var(--fg-dim);
  background: linear-gradient( to bottom, rgba(0,255,120,.08), transparent );
}
header .brand {
  display: flex; gap: 12px; align-items: center; white-space: pre; overflow-x: auto;
  font-size: 14px; color: var(--fg);
}
header .brand .cursor { animation: blink 1s steps(1,end) infinite; }
@keyframes blink { 50% { opacity: 0; } }

nav {
  border-right: 1px solid var(--fg-dim); padding: 1rem; position: relative; z-index: 2;
}
nav h2 { font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--fg-dim); margin: 0 0 .5rem; }
nav a { display: block; color: var(--link); text-decoration: none; padding: .25rem 0; }
nav a:focus, nav a:hover { text-decoration: underline; }

main { position: relative; z-index: 2; }
.toolbar { display: flex; flex-wrap: wrap; gap: .5rem; padding: .75rem 1rem; border-bottom: 1px dashed var(--fg-dim); }
.toolbar input[type="search"] {
  background: #061a06; color: var(--fg); border: 1px solid var(--fg-dim); padding: .4rem .6rem; width: 260px;
}
.toolbar button { background: #061a06; color: var(--fg); border: 1px solid var(--fg-dim); padding: .4rem .6rem; cursor: pointer; }
.toolbar button[aria-pressed="true"] { outline: 2px solid var(--accent); }

.marquee {
  border-bottom: 1px dashed var(--fg-dim); padding: .25rem 1rem; font-size: 12px; color: var(--fg-dim);
}
.marquee .mtext { display: inline-block; animation: scroll 28s linear infinite; }
@keyframes scroll { from { transform: translateX(100%);} to { transform: translateX(-100%);} }

.content { padding: 1rem; }

.panel { border: 1px solid var(--fg-dim); box-shadow: 0 0 0 2px var(--shadow); padding: 1rem; margin-bottom: 1rem; background: rgba(0, 30, 0, 0.3); }
.panel h3 { margin-top: 0; }

.filelist { width: 100%; border-collapse: collapse; }
.filelist th, .filelist td { border-bottom: 1px solid #0e3e0e; padding: .5rem .4rem; font-size: 14px; }
.filelist th { text-align: left; color: var(--fg-dim); font-weight: normal; }
.tag { border: 1px solid var(--fg-dim); padding: 0 .25rem; font-size: 11px; margin-left: .25rem; color: var(--accent); }
.kbd { border: 1px solid var(--fg-dim); padding: 0 .25rem; font-size: 11px; }

a { color: var(--link); }

/* Matrix canvas background */
#matrix-bg { position: fixed; inset: 0; z-index: 0; opacity: .2; }

/* Terminal overlay */
.overlay {
  position: fixed; inset: 6vh 6vw; background: rgba(0, 0, 0, .96); border: 1px solid var(--fg-dim); 
  box-shadow: 0 0 0 2px var(--shadow); display: none; z-index: 9999; color: var(--fg);
}
.overlay header { border-bottom: 1px dashed var(--fg-dim); }
.terminal { padding: 1rem; height: calc(100% - 46px); overflow: auto; }
.term-line { display: flex; gap: .5rem; align-items: baseline; }
.term-prompt { color: var(--accent); }
.term-input { background: #031903; color: var(--fg); border: 1px dashed var(--fg-dim); width: 100%; padding: .3rem .4rem; }

/* Hidden deep archive */
#deep-archive { display: none; }

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .marquee .mtext { animation: none; }
  body::before { display: none; }
}

/* Small screens: stack nav */
@media (max-width: 860px) {
  .grid { grid-template-columns: 1fr; }
  nav { border-right: none; border-bottom: 1px solid var(--fg-dim); display: grid; grid-template-columns: repeat(auto-fit,minmax(180px,1fr)); gap: .25rem 1rem; }
  nav a { padding: .35rem 0; }
}
