:root {
  --bg: #0d1117;
  --panel: #161b22;
  --panel-2: #1c232d;
  --border: #2a3441;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #4f8cff;
  --accent-2: #3b6fd6;
  --green: #3fb950;
  --red: #f85149;
  --teams: #5059c9;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif;
  background: radial-gradient(1200px 600px at 50% -10%, #15203050, transparent),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
}

#app {
  max-width: 760px;
  margin: 0 auto;
  padding: 32px 20px 80px;
  min-height: 100vh;
}

/* Screens */
.screen {
  display: none;
  animation: fade 0.25s ease;
}
.screen.active {
  display: block;
}
@keyframes fade {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* Home */
.brand {
  text-align: center;
  margin: 8vh 0 6vh;
}
.logo {
  font-size: 64px;
  line-height: 1;
}
.brand h1 {
  font-size: 40px;
  margin: 12px 0 6px;
  letter-spacing: -0.5px;
}
.tagline {
  color: var(--muted);
  margin: 0;
}
.home-actions {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 320px;
  margin: 0 auto;
}

/* Buttons */
.btn {
  font: inherit;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 14px 20px;
  cursor: pointer;
  transition: 0.15s ease;
  color: var(--text);
  background: var(--panel-2);
}
.btn:hover {
  filter: brightness(1.1);
}
.btn:active {
  transform: translateY(1px);
}
.btn.primary {
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  border-color: var(--accent-2);
}
.btn.ghost {
  background: var(--panel);
  border-color: var(--border);
}
.btn.link {
  background: none;
  border: none;
  color: var(--muted);
  padding: 8px;
}
.btn.link:hover {
  color: var(--text);
}
.btn.link.danger,
.btn .danger {
  color: var(--red);
}
.btn.small {
  padding: 10px 14px;
  border-radius: 10px;
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Create / Join */
#screen-create,
#screen-join {
  text-align: center;
  max-width: 420px;
  margin: 8vh auto 0;
}
.sub {
  color: var(--muted);
  margin-top: -6px;
}
.code-display {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin: 24px 0;
}
.code-display span {
  flex: 1;
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 0;
  font-size: clamp(20px, 6vw, 30px);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  user-select: all;
}

/* Camera-scan-overlay */
.scan-overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: #000;
}
.scan-overlay.active {
  display: flex;
}
#scan-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.scan-frame {
  position: relative;
  width: min(70vw, 280px);
  aspect-ratio: 1;
  border: 3px solid #fff;
  border-radius: 18px;
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.5);
}
.scan-hint,
.scan-overlay .btn {
  position: relative;
  color: #fff;
  text-align: center;
}
.scan-hint {
  font-weight: 600;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
}

/* QR-code (witte kaart voor goed contrast/scanbaarheid) */
.qr-block {
  margin: 4px 0 18px;
}
.qr {
  width: 200px;
  max-width: 60vw;
  margin: 0 auto;
  background: #fff;
  padding: 12px;
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.qr svg {
  display: block;
  width: 100%;
  height: auto;
}
.qr:empty {
  display: none;
}
.qr-hint {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  margin: 10px 0 0;
}
#qr-overlay {
  width: 180px;
  margin-top: 14px;
}

/* Modus-keuze (relay vs direct) */
.mode-toggle {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.mode-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
  align-items: center;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  padding: 12px 8px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--muted);
  transition: 0.15s ease;
}
.mode-btn small {
  font-weight: 400;
  font-size: 11px;
  opacity: 0.8;
}
.mode-btn:hover {
  border-color: var(--accent);
}
.mode-btn.active {
  color: var(--text);
  border-color: var(--accent);
  background: linear-gradient(180deg, #16243a, var(--panel));
  box-shadow: inset 0 0 0 1px var(--accent);
}
.badge.transport {
  color: var(--text);
}
.code-input {
  width: 100%;
  font-size: 32px;
  text-align: center;
  letter-spacing: 10px;
  padding: 20px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  margin: 24px 0;
  font-variant-numeric: tabular-nums;
}
.code-input:focus {
  outline: none;
  border-color: var(--accent);
}
#screen-create .btn,
#screen-join .btn {
  width: 100%;
  margin-bottom: 10px;
}

/* Overlay */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 11, 16, 0.92);
  backdrop-filter: blur(4px);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 50;
}
.overlay.active {
  display: flex;
}
.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.overlay-code {
  color: var(--muted);
}
.overlay-code span {
  letter-spacing: 4px;
  font-weight: 700;
  color: var(--text);
}

/* Active tunnel */
.tunnel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
}
.status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}
.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 0 rgba(63, 185, 80, 0.6);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(63, 185, 80, 0.5);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(63, 185, 80, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(63, 185, 80, 0);
  }
}
.badge {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 1px 9px;
  font-size: 13px;
  color: var(--muted);
}
.meta {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 14px;
  color: var(--muted);
}
.sas strong {
  letter-spacing: 2px;
  color: var(--text);
}
.countdown {
  font-variant-numeric: tabular-nums;
}

/* Composer */
.composer {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.row {
  display: flex;
  gap: 10px;
  align-items: center;
}
.text-input {
  flex: 1;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  color: var(--text);
  font: inherit;
  resize: none;
  max-height: 160px;
  line-height: 1.4;
}
.text-input:focus {
  outline: none;
  border-color: var(--accent);
}
.file-label {
  cursor: pointer;
}
.hint {
  color: var(--muted);
  font-size: 13px;
}

/* Feed */
.feed {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.item {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  animation: fade 0.2s ease;
}
.item.out {
  border-color: #2b3a52;
  background: linear-gradient(180deg, #141d2b, var(--panel));
}
.item .icon {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--panel-2);
}
.item .icon.teams {
  background: var(--teams);
}
.item .icon svg {
  width: 20px;
  height: 20px;
}
.item .body {
  flex: 1;
  min-width: 0;
}
.item .title {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.item .title a {
  color: var(--accent);
  text-decoration: none;
}
.item .title a:hover {
  text-decoration: underline;
}

/* Tekstbericht / chat-bubbel */
.item.bubble {
  display: block;
  max-width: 80%;
  width: fit-content;
}
.item.bubble.out {
  margin-left: auto; /* eigen berichten rechts */
}
.bubble .msg-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.45;
}
.bubble .msg-text a {
  color: var(--accent);
}
.bubble .msg-foot {
  display: flex;
  justify-content: flex-end;
  margin-top: 6px;
}
.bubble .msg-foot .iconbtn {
  padding: 4px 9px;
  font-size: 12px;
}
.item .desc {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}
.item .actions {
  display: flex;
  gap: 6px;
  flex: 0 0 auto;
}
.iconbtn {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  cursor: pointer;
  color: var(--text);
  font-size: 13px;
}
.iconbtn:hover {
  border-color: var(--accent);
}
.iconbtn.accept {
  background: var(--green);
  border-color: var(--green);
  color: #05210c;
}
.iconbtn.reject {
  color: var(--red);
}
.thumb {
  display: block;
  max-width: 100%;
  max-height: 240px;
  border-radius: 10px;
  margin-top: 10px;
  cursor: zoom-in;
  border: 1px solid var(--border);
}
.progress {
  height: 6px;
  border-radius: 4px;
  background: var(--panel-2);
  overflow: hidden;
  margin-top: 8px;
}
.progress > div {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.15s linear;
}
.sys {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 6px;
}

/* Sleep-overlay */
.dropzone {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(13, 17, 23, 0.85);
  backdrop-filter: blur(3px);
}
.dropzone.active {
  display: flex;
}
.dropzone-inner {
  border: 2px dashed var(--accent);
  border-radius: 18px;
  padding: 44px 60px;
  text-align: center;
  background: rgba(79, 140, 255, 0.07);
  pointer-events: none;
}
.dropzone-inner p {
  margin: 8px 0 4px;
  font-size: 20px;
  font-weight: 700;
}
.dropzone-inner small {
  color: var(--muted);
}
.dz-icon {
  font-size: 52px;
  line-height: 1;
}

@media (max-width: 520px) {
  .tunnel-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .composer .row {
    flex-wrap: wrap;
  }
}
