:root {
  --bg: #0a0f1e;
  --panel: rgba(16, 24, 44, 0.72);
  --border: rgba(0, 212, 255, 0.16);
  --text: #d6e2f5;
  --muted: #7a8aa8;
  --green: #00ff88;
  --cyan: #00d4ff;
  --red: #ff3860;
  --yellow: #febc2e;
  --radius: 12px;
  --font: "JetBrains Mono", "Fira Code", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

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

[hidden] { display: none !important; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--green); color: var(--bg); }

.grid-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(0, 212, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 212, 255, 0.045) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at 50% 40%, #000 20%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse at 50% 40%, #000 20%, transparent 75%);
}

.scanlines {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.022) 0px,
    rgba(255, 255, 255, 0.022) 1px,
    transparent 1px,
    transparent 3px
  );
}

/* ---------- Navigatie ---------- */
.nav {
  position: relative;
  z-index: 2;
  background: rgba(10, 15, 30, 0.85);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  max-width: 760px;
  margin: 0 auto;
  padding: 0.8rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.85rem;
}

.nav-inner a { text-decoration: none; color: inherit; }
.nav-prompt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user { color: var(--green); }
.path { color: var(--cyan); }

.caret {
  display: inline-block;
  width: 0.55em;
  height: 1em;
  background: var(--green);
  vertical-align: -0.12em;
  margin-left: 0.2em;
  animation: blink 1s steps(1) infinite;
}

@keyframes blink { 50% { opacity: 0; } }

.status {
  flex-shrink: 0;
  font-size: 0.72rem;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.status::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--yellow);
}

.status.on { color: var(--green); }
.status.on::before { background: var(--green); box-shadow: 0 0 8px var(--green); }

/* ---------- Layout ---------- */
main {
  position: relative;
  z-index: 2;
  flex: 1;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 2rem 1rem 3rem;
}

.terminal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45), 0 0 40px rgba(0, 255, 136, 0.06);
}

.terminal-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0.55rem 0.8rem;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid var(--border);
}

.terminal-bar span { width: 10px; height: 10px; border-radius: 50%; }
.terminal-bar span:nth-child(1) { background: #ff5f57; }
.terminal-bar span:nth-child(2) { background: #febc2e; }
.terminal-bar span:nth-child(3) { background: #28c840; }

.terminal-bar em {
  margin-left: auto;
  font-style: normal;
  font-size: 0.7rem;
  color: var(--muted);
}

.terminal-body { padding: 1.5rem 1.25rem; }

section { animation: fade-in 0.35s ease both; }

@keyframes fade-in {
  from { opacity: 0; transform: translateY(8px); }
}

h1, h2 {
  font-size: clamp(1.2rem, 4.5vw, 1.6rem);
  color: #fff;
  text-shadow: 0 0 20px rgba(0, 255, 136, 0.3);
  margin-bottom: 0.4rem;
}

h2 { font-size: 1.2rem; }

.sub { color: var(--muted); font-size: 0.85rem; }
.hl { color: var(--green); font-weight: 500; }
.line { font-size: 0.85rem; color: var(--muted); margin-bottom: 1rem; }
.prompt { color: var(--green); }
.hint { margin-top: 0.6rem; font-size: 0.75rem; color: var(--muted); min-height: 1.2em; }
.hint.err { color: var(--red); }

.dots::after {
  content: "";
  animation: dots 1.4s steps(4) infinite;
}

@keyframes dots {
  0% { content: ""; }
  25% { content: "."; }
  50% { content: ".."; }
  75% { content: "..."; }
}

/* ---------- Knoppen ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  text-decoration: none;
  padding: 0.7rem 1.1rem;
  border-radius: 8px;
  border: 1px solid var(--green);
  color: var(--bg);
  background: var(--green);
  cursor: pointer;
  transition: box-shadow 0.25s, transform 0.25s, background 0.25s;
}

.btn:hover, .btn:focus-visible {
  box-shadow: 0 0 24px rgba(0, 255, 136, 0.55);
  transform: translateY(-2px);
  outline: none;
}

.btn.ghost { background: transparent; color: var(--green); }
.btn.ghost:hover, .btn.ghost:focus-visible { background: rgba(0, 255, 136, 0.08); }

.btn.danger { background: transparent; color: var(--red); border-color: var(--red); }
.btn.danger:hover, .btn.danger:focus-visible { background: rgba(255, 56, 96, 0.08); box-shadow: 0 0 20px rgba(255, 56, 96, 0.35); }

.btn.small { padding: 0.35rem 0.7rem; font-size: 0.75rem; }

.row { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1.4rem; }

/* ---------- Meedoen ---------- */
.join {
  margin-top: 2rem;
  padding-top: 1.4rem;
  border-top: 1px dashed var(--border);
}

.join label { display: block; font-size: 0.8rem; color: var(--muted); margin-bottom: 0.5rem; }

.join-row { display: flex; gap: 0.6rem; }

.join input {
  flex: 1;
  min-width: 0;
  font-family: inherit;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #fff;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.8rem;
}

.join input:focus { outline: none; border-color: var(--green); box-shadow: 0 0 16px rgba(0, 255, 136, 0.25); }

/* ---------- Host ---------- */
.share {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.5rem;
  margin-top: 1.4rem;
}

.code {
  font-size: clamp(2rem, 11vw, 3rem);
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--green);
  text-shadow: 0 0 30px rgba(0, 255, 136, 0.4);
}

.qr {
  background: #fff;
  border-radius: 8px;
  padding: 6px;
  line-height: 0;
}

.qr:empty { display: none; }
.qr svg { width: 132px; height: 132px; }

/* ---------- Drop-zone ---------- */
.drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  min-height: 190px;
  padding: 1.5rem;
  text-align: center;
  border: 2px dashed rgba(0, 255, 136, 0.35);
  border-radius: var(--radius);
  background: rgba(0, 255, 136, 0.03);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

.drop:hover, .drop:focus-within, .drop.over {
  border-color: var(--green);
  background: rgba(0, 255, 136, 0.08);
  box-shadow: 0 0 30px rgba(0, 255, 136, 0.15) inset;
}

.drop-icon { font-size: 2rem; color: var(--green); }
.drop-title { font-weight: 700; color: #fff; }
.drop-sub { font-size: 0.78rem; color: var(--muted); }

.drop-alt { margin-top: 0.5rem; font-size: 0.75rem; color: var(--muted); text-align: center; }

.link {
  font: inherit;
  color: var(--green);
  background: none;
  border: none;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.link:hover, .link:focus-visible { color: #fff; outline: none; }

/* ---------- Verbonden apparaten ---------- */
.peers {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.peers:empty { display: none; }

.peer {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.3rem 0.4rem 0.3rem 0.7rem;
  font-size: 0.75rem;
  border: 1px solid rgba(0, 255, 136, 0.35);
  border-radius: 999px;
  background: rgba(0, 255, 136, 0.06);
}

.peer::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
}

.peer.pending { border-color: rgba(254, 188, 46, 0.4); background: rgba(254, 188, 46, 0.06); }
.peer.pending::before { background: var(--yellow); box-shadow: none; }
.peer:not(:has(.peer-x)) { padding-right: 0.7rem; }

.peer-x {
  width: 1.4rem;
  height: 1.4rem;
  font: inherit;
  line-height: 1;
  color: var(--muted);
  background: none;
  border: none;
  border-radius: 50%;
  cursor: pointer;
}

.peer-x:hover, .peer-x:focus-visible { color: var(--red); background: rgba(255, 56, 96, 0.12); outline: none; }

/* ---------- Gedeelde bestanden ---------- */
.outbox {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem 1rem;
  margin-bottom: 1.2rem;
  padding: 0.6rem 0.8rem;
  font-size: 0.78rem;
  border: 1px dashed var(--cyan);
  border-radius: 8px;
  background: rgba(0, 212, 255, 0.05);
}

.outbox .link { color: var(--cyan); }

/* ---------- Overdrachten ---------- */
.transfers {
  margin-top: 1.4rem;
  padding-top: 1.2rem;
  border-top: 1px dashed var(--border);
}

.files-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  min-height: 2rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.files { display: grid; gap: 0.5rem; margin-top: 0.6rem; }

.file {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 0.4rem 0.75rem;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
  font-size: 0.8rem;
}

.file .dir { font-weight: 700; }
.file .dir.out { color: var(--cyan); }
.file .dir.in { color: var(--green); }
.file .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #fff; }
.file .who { margin-left: 0.5rem; font-size: 0.7rem; color: var(--muted); }

.file .thumb {
  grid-column: 1 / -1;
  display: block;
  max-width: 100%;
  max-height: 180px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.25);
}
.file .meta { color: var(--muted); font-size: 0.72rem; white-space: nowrap; }
.file .bar {
  grid-column: 1 / -1;
  height: 3px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.file .bar i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--green), var(--cyan));
  transition: width 0.15s linear;
}

.file.done .bar { display: none; }

.file .snippet {
  grid-column: 1 / -1;
  max-height: 12rem;
  overflow: auto;
  margin: 0;
  padding: 0.6rem 0.7rem;
  font: inherit;
  color: var(--text);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 6px;
}

/* ---------- Tekst versturen ---------- */
.text-send { margin-top: 1rem; }
.text-send label { display: block; font-size: 0.8rem; color: var(--muted); margin-bottom: 0.5rem; }

.text-send textarea {
  display: block;
  width: 100%;
  min-height: 5rem;
  resize: vertical;
  font-family: inherit;
  font-size: 0.85rem;
  color: #fff;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
}

.text-send textarea:focus { outline: none; border-color: var(--green); box-shadow: 0 0 16px rgba(0, 255, 136, 0.25); }

.text-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-top: 0.6rem;
}

.text-row .hint { margin: 0; min-height: 0; }
.file.failed .meta { color: var(--red); }

/* ---------- Dialog ---------- */
dialog {
  margin: auto;
  width: min(420px, calc(100% - 2rem));
  color: var(--text);
  background: #0e1528;
  border: 1px solid var(--green);
  border-radius: var(--radius);
  padding: 1.4rem 1.25rem;
  box-shadow: 0 0 40px rgba(0, 255, 136, 0.2);
}

dialog::backdrop { background: rgba(5, 8, 16, 0.75); backdrop-filter: blur(3px); }

footer {
  position: relative;
  z-index: 2;
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted);
  padding: 1.5rem 1rem;
  border-top: 1px solid var(--border);
}

@media (max-width: 480px) {
  .join-row { flex-direction: column; }
  .file { grid-template-columns: auto 1fr auto; }
  .file .meta { grid-column: 2; grid-row: 2; white-space: normal; }
  .row .btn { flex: 1; }
}

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