:root {
  --bg: #000;
  --fg: #00ff66;
  --fg-dim: #00b34d;
  --fg-faint: #005f28;
  --accent: #33ff99;
  --danger: #ff2d55;
  --warn: #ffcc00;
  --mono: 'Fira Code', 'Cascadia Code', 'JetBrains Mono', Consolas, 'SF Mono', Menlo, monospace;
  --glow: 0 0 2px rgba(0,255,102,.6), 0 0 8px rgba(0,255,102,.35), 0 0 16px rgba(0,255,102,.15);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
  text-shadow: var(--glow);
  -webkit-font-smoothing: antialiased;
}

#rain {
  position: fixed; inset: 0; z-index: 0;
  opacity: .45;
  pointer-events: none;
}

.scanlines {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0,0,0,0) 0,
    rgba(0,0,0,0) 2px,
    rgba(0,0,0,.25) 3px,
    rgba(0,0,0,0) 4px
  );
  mix-blend-mode: multiply;
  animation: flick 7s infinite steps(1);
}
.vignette {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,.85) 100%);
}

@keyframes flick {
  0%,97%,100% { opacity: 1; }
  98% { opacity: .88; }
  99% { opacity: .95; }
}

.terminal {
  position: relative; z-index: 2;
  max-width: 880px;
  margin: 4vh auto 2vh;
  height: 92vh;
  border: 1px solid var(--fg-dim);
  box-shadow: 0 0 30px rgba(0,255,102,.25), inset 0 0 40px rgba(0,255,102,.06);
  background: rgba(0, 10, 4, .82);
  backdrop-filter: blur(2px);
  display: flex; flex-direction: column;
  overflow: hidden;
}

.term-head {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--fg-faint);
  background: linear-gradient(to bottom, rgba(0,255,102,.06), transparent);
}
.dots { display: flex; gap: 6px; }
.dots span {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--fg-faint); box-shadow: var(--glow);
}
.dots span:nth-child(1) { background: #ff5f57; }
.dots span:nth-child(2) { background: #febc2e; }
.dots span:nth-child(3) { background: #28c840; }
.title { flex: 1; font-size: 12px; letter-spacing: 1px; text-transform: uppercase; color: var(--fg); }
.status { font-size: 11px; color: var(--fg-dim); }

.pane {
  flex: 1;
  padding: 24px 28px;
  display: none;
  flex-direction: column;
  gap: 18px;
  overflow: auto;
}
.pane.active { display: flex; }

.ascii {
  color: var(--fg);
  margin: 0;
  font-size: 14px;
  line-height: 1.05;
  white-space: pre;
  text-shadow: var(--glow);
}
.ascii.small { font-size: 13px; }

.blurb { margin: 0; font-size: 15px; }
.typed::after {
  content: ''; display: inline-block;
  width: 9px; height: 15px; background: var(--fg);
  margin-left: 2px; transform: translateY(2px);
  animation: blink 1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.bullets {
  list-style: none; padding: 0; margin: 0;
  display: grid; gap: 4px;
}
.bullets li::before {
  content: '> '; color: var(--fg-dim);
}

.actions { margin-top: 8px; }
.fineprint { color: var(--fg-dim); font-size: 12px; margin: 0; }

.btn {
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--fg-dim);
  padding: 10px 18px;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  letter-spacing: 1px;
  text-transform: uppercase;
  text-shadow: var(--glow);
  transition: background .12s, transform .05s, border-color .12s;
}
.btn:hover { background: rgba(0,255,102,.08); border-color: var(--fg); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  border-color: var(--fg);
  box-shadow: 0 0 12px rgba(0,255,102,.35), inset 0 0 12px rgba(0,255,102,.08);
}
.btn.ghost { border-color: var(--fg-faint); color: var(--fg-dim); }
.btn:disabled { opacity: .4; cursor: not-allowed; }

.loader { display:flex; justify-content:center; padding: 12px 0; }
.spinner {
  width: 40px; height: 40px;
  border: 2px solid var(--fg-faint);
  border-top-color: var(--fg);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  box-shadow: var(--glow);
}
@keyframes spin { to { transform: rotate(360deg); } }

.link-box {
  display: flex; gap: 8px;
  border: 1px dashed var(--fg-dim);
  padding: 8px; align-items: stretch;
}
.link-box input {
  flex: 1; background: transparent; color: var(--fg);
  border: none; outline: none;
  font-family: inherit; font-size: 13px;
  text-shadow: var(--glow);
  overflow: hidden; text-overflow: ellipsis;
}

.fp-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 12px; }
.fp-row.small { font-size: 11px; }
.fp-row code {
  background: rgba(0,255,102,.08);
  padding: 2px 6px; border: 1px solid var(--fg-faint);
  letter-spacing: 1.5px;
}
.fp-row .hint { color: var(--fg-dim); font-size: 11px; }

.muted { color: var(--fg-dim); }

/* Chat */
.chat-head { display: flex; flex-direction: column; gap: 6px; }
.secure-badge {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px;
  border: 1px solid var(--fg);
  align-self: flex-start;
  font-size: 12px; letter-spacing: 1px;
  background: rgba(0,255,102,.05);
}
.secure-badge .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--fg); box-shadow: 0 0 8px var(--fg);
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse {
  0%,100% { opacity: 1; transform: scale(1); }
  50% { opacity: .55; transform: scale(.85); }
}

.messages {
  list-style: none; padding: 0; margin: 0;
  flex: 1;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 10px;
  padding-right: 6px;
  scrollbar-width: thin;
  scrollbar-color: var(--fg-dim) transparent;
}
.messages::-webkit-scrollbar { width: 8px; }
.messages::-webkit-scrollbar-thumb { background: var(--fg-faint); }

.messages li {
  max-width: 82%;
  padding: 8px 12px;
  border: 1px solid var(--fg-faint);
  background: rgba(0,255,102,.04);
  white-space: pre-wrap;
  word-break: break-word;
  animation: decrypt .25s ease-out;
  position: relative;
}
@keyframes decrypt {
  from { opacity: 0; filter: blur(3px); transform: translateY(3px); }
  to   { opacity: 1; filter: none;    transform: none; }
}

.messages li.me {
  align-self: flex-end;
  border-color: var(--fg);
  background: rgba(0,255,102,.1);
}
.messages li.sys {
  align-self: center;
  border: none;
  background: transparent;
  color: var(--fg-dim);
  font-size: 12px;
  max-width: 100%;
  padding: 4px 8px;
  animation: none;
}
.messages li .ts {
  display: block;
  font-size: 10px;
  color: var(--fg-dim);
  margin-top: 4px;
  letter-spacing: 1px;
}

.composer {
  display: flex; gap: 8px;
  border-top: 1px solid var(--fg-faint);
  padding-top: 12px;
}
.composer textarea {
  flex: 1;
  background: rgba(0,0,0,.4);
  color: var(--fg);
  border: 1px solid var(--fg-faint);
  padding: 10px 12px;
  font-family: inherit; font-size: 14px;
  resize: none;
  outline: none;
  text-shadow: var(--glow);
  max-height: 200px;
}
.composer textarea:focus { border-color: var(--fg); }

.btn.attach {
  padding: 10px 12px;
  font-size: 16px;
  border-color: var(--fg-faint);
  color: var(--fg);
}

/* Secure badge — P2P variant */
.secure-badge.p2p {
  border-color: var(--accent);
  background: rgba(51,255,153,.08);
  color: var(--accent);
}
.secure-badge.p2p .dot { background: var(--accent); box-shadow: 0 0 8px var(--accent); }

/* File messages */
.messages li.file { padding: 10px 12px; min-width: 240px; }
.messages li.file .file-row {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 6px;
}
.messages li.file .file-icon {
  font-size: 20px; color: var(--fg);
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--fg-faint);
}
.messages li.file .file-info { flex: 1; min-width: 0; }
.messages li.file .file-name {
  font-size: 13px; color: var(--fg);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.messages li.file .file-meta {
  font-size: 10px; color: var(--fg-dim);
  letter-spacing: 1px;
}
.file-progress {
  height: 3px;
  background: rgba(0,255,102,.15);
  overflow: hidden;
  margin: 4px 0 6px;
}
.file-bar {
  display: block; height: 100%;
  background: var(--fg);
  box-shadow: 0 0 6px var(--fg);
  transition: width .15s linear;
}
.file-preview { margin-top: 6px; }
.file-preview img {
  max-width: 100%;
  max-height: 260px;
  border: 1px solid var(--fg-faint);
  display: block;
  cursor: zoom-in;
  filter: saturate(1.1);
}
.file-preview .btn { display: inline-block; margin-top: 4px; font-size: 11px; }

/* Drop overlay */
.drop-overlay {
  position: absolute; inset: 0;
  display: none;
  align-items: center; justify-content: center;
  background: rgba(0,30,10,.85);
  border: 2px dashed var(--fg);
  font-size: 18px; letter-spacing: 3px;
  pointer-events: none;
  z-index: 5;
  text-shadow: var(--glow);
}
#chat.dropping .drop-overlay { display: flex; animation: pulseBg 1s ease-in-out infinite; }
@keyframes pulseBg {
  0%,100% { background: rgba(0,30,10,.85); }
  50%     { background: rgba(0,60,20,.85); }
}
#chat { position: relative; }

.chat-foot {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 11px; color: var(--fg-dim);
  border-top: 1px solid var(--fg-faint);
  padding-top: 8px;
  gap: 12px;
}
.foot-actions { display: flex; gap: 8px; align-items: center; }
.btn.sound {
  padding: 6px 10px;
  font-size: 14px;
  border-color: var(--fg-faint);
  line-height: 1;
}
.peer-status::before {
  content: '● '; color: var(--fg);
}
.peer-status.off { color: var(--danger); }
.peer-status.off::before { color: var(--danger); }

.footnote {
  position: fixed; bottom: 6px; left: 0; right: 0;
  text-align: center;
  font-size: 10px; color: var(--fg-faint);
  z-index: 2;
}
.footnote a { color: var(--fg-dim); text-decoration: none; border-bottom: 1px dotted var(--fg-faint); }

.modal {
  position: fixed; inset: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.75);
  padding: 20px;
}
.modal[hidden] { display: none; }
.modal-box {
  max-width: 560px; width: 100%;
  border: 1px solid var(--fg);
  background: rgba(0,10,4,.95);
  padding: 24px;
  box-shadow: 0 0 30px rgba(0,255,102,.4);
}
.modal-box h3 { margin: 0 0 12px; color: var(--fg); }
.modal-box p { margin: 0 0 12px; }

@media (max-width: 640px) {
  .terminal { margin: 0; height: 100vh; border: none; }
  .ascii { font-size: 10px; }
  .pane { padding: 16px; }
}
