/* ========== Global Reset & App-Like Behavior (no page zoom/scroll) ========== */
* {
  box-sizing: border-box;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
  background: #0a0a0a;
  color: #eaeaea;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-overflow-scrolling: auto;
  touch-action: manipulation;
  position: relative;

  /* restore your original system font stack */
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  /* optional: slightly crisper rendering */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Body-wide neon glow via a fixed overlay frame */
body::before {
  content: '';
  position: fixed;
  inset: 8px;
  border-radius: 14px;
  pointer-events: none;
  z-index: 999;
  border: 2px solid transparent;
}

/* Director = neon blue */
body.role-director::before {
  border-color: rgba(80, 150, 255, 0.8);
  box-shadow:
    0 0 18px rgba(51, 153, 255, 0.85) inset,
    0 0 26px rgba(51, 153, 255, 0.35),
    0 0 46px rgba(51, 153, 255, 0.25);
}

/* Peer = neon green */
body.role-peer::before {
  border-color: rgba(80, 255, 150, 0.85);
  box-shadow:
    0 0 18px rgba(0, 255, 153, 0.85) inset,
    0 0 26px rgba(0, 255, 153, 0.35),
    0 0 46px rgba(0, 255, 153, 0.25);
}

/* ========== App Layout: header (fixed height), content, footer ========== */
#app {
  max-width: 960px;
  margin: 0 auto;
  padding: 16px;
  padding-bottom: 0;
  /* keep fixed elements off the layout calc */
  min-height: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* --- Header: fixed positions (no responsive reflow) --- */
header {
  position: relative;
  padding: 10px 12px 0 12px;
  text-align: center;
  flex: 0 0 auto;
  z-index: 960;
  /* above content, below open sheet */
}

header h1 {
  margin: 0;
  font-size: 30px;
  font-weight: 700;
  line-height: 1.2;
}

/* Leave button always top-left */
.leaveBtn {
  position: absolute;
  top: 12px;
  left: 12px;
  background: #2a2a2a0c;
  border: none;
  padding: 6px 10px;
  font-size: 22px;
}

.status {
  opacity: 0.85;
  font-size: 12px;
  margin: 6px 0 6px 0;
}

/* QR button top-right */
.qrBtn {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  cursor: pointer;
  color: #fff;
  padding: 6px;
  border-radius: 6px;
  transition: background 0.2s;
}

.qrBtn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.qrBtn svg {
  display: block;
  width: 32px;
  height: 32px;
}

/* Remove previous responsive header behavior */
@media (min-width: 0) {
  /* intentionally empty to override older rules */
}

/* ========== Content Sections ========== */
section {
  margin: 18px 0;
  padding: 12px;
  flex: 0 0 auto;
}

section h2 {
  margin-top: 0;
  font-size: 16px;
}

.hidden {
  display: none !important;
}

.row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 8px 0;
}

.column {
  display: flex;
  flex-direction: column;
  align-items:center;
  gap: 30px;
}

.column input {
  width: 100%;
}

.row.center {
  justify-content: center;
}
/* Stack the join inputs vertically (only for the join section) */
#joinSection {
  text-align: center;
}
#joinBtn {
  width: fit-content;
}

input,
button,
label {
  font-size: 14px;
  -webkit-user-select: text;
  user-select: text;
  /* allow text selection in inputs/labels */
}

input[type="text"],
input[type="file"],
input[type="range"],
input#swarmName,
input#swarmSecret {
  background: #1a1a1a;
  color: #eaeaea;
  border: 1px solid #333;
  padding: 8px;
  border-radius: 4px;
}

button {
  background: #222;
  color: #fafafa;
  border: 1px solid #333;
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.hint {
  opacity: 0.7;
  font-size: 12px;
}

/* ========== Files Screen: the ONLY scrollable region ========== */
#screenFiles {
  flex: 1 1 auto;
  /* take remaining height between header and fixed UI */
  min-height: 0;
  /* allow child to shrink/scroll properly */
  display: flex;
  flex-direction: column;
  margin-top: 12px;
}

/* Only this element scrolls */
#fileList {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  overflow: auto;
  /* <- the one scrollable area */
  -webkit-overflow-scrolling: touch;
  padding-bottom: 180px;
  /* leave room for play button & sheet peek */
}

/* File rows */
.file-row {
  padding: 10px 12px;
  border: 1px solid #222;
  border-radius: 10px;
  background: #0f0f0f;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: box-shadow 140ms ease, border-color 140ms ease;
}

.file-row.placeholder {
  opacity: 0.6;
}

.file-row .name {
  font-size: 14px;
}

/* Badges */
.badge {
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 12px;
  background: #222;
  border: 1px solid #333;
}

.badge.ready {
  background: #143016;
  border-color: #1f5f25;
}

.badge.fetching {
  background: #2a1d10;
  border-color: #7a4a12;
}

.badge.seeding {
  background: #10232d;
  border-color: #1e5a7a;
}

.badge.error {
  background: #3a1414;
  border-color: #7a1e1e;
}

/* Neon highlights for selections */
.file-row.selected-director {
  border-color: #6cc0ff;
  box-shadow:
    0 0 6px rgba(51, 153, 255, 0.9),
    0 0 14px rgba(51, 153, 255, 0.45);
}

.file-row.selected-local {
  border-color: #7fffd0;
  box-shadow:
    0 0 6px rgba(0, 255, 153, 0.9),
    0 0 14px rgba(0, 255, 153, 0.45);
}

/* Debug log: if you want ONLY file list to scroll, keep this non-scrollable. */
pre#debugLog {
  max-height: 180px;
  overflow: hidden;
  /* set to 'auto' if you want it scrollable */
  background: #0b0b0b;
  border: 1px solid #222;
  padding: 8px;
  border-radius: 8px;
}

/* Delay controls */
#delaySlider {
  width: 100%;
}

.delayAdjust {
  display: flex;
  align-items: center;
  gap: 10px;
}

.delayBox {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.delayVal {
  text-align: center;
  font-size: 14px;
  opacity: 0.9;
}

.nudgeBtn {
  width: 80px;
  height: 80px;
  border-radius: 8px;
  background: #1d1d1d;
  border: 1px solid #333;
  font-size: 18px;
  touch-action: manipulation;
}

/* Hidden file input */
.hidden-input {
  display: none;
}

/* Controls container & takeover btn */
.controlsContainer {
  margin-top: 8px;
  padding: 12px;
  border: 1px solid #222;
  border-radius: 12px;
  background: #121212;
}

.controlsHeader {
  text-align: center;
  opacity: 0.8;
  margin-bottom: 12px;
}

.takeoverBtn {
  background: #0f2e21;
  border: 1px solid #1ca36d;
  color: #98ffd9;
  border-radius: 10px;
  padding: 8px 12px;
}

.takeoverBtn:hover {
  filter: brightness(1.08);
}

/* ========== Play Section: fixed footer above sheet peek; starts hidden ========== */
#playSection {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 68px;
  z-index: 950;
  /* below overlay (1000) and open sheet (1001) */
  background: transparent;
  border: none;
  margin: 0;
  padding: 10px 0 18px 0;
  pointer-events: auto;
}

.primaryPlay {
  background-color: transparent;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
}

.primaryPlay svg {
  width: 120px;
  height: 120px;
}

.primaryPlay:disabled {
  opacity: 0.5;
}

/* ========== Bottom Sheet overlay and panel ========== */
.sheetOverlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
  z-index: 980;
}

.sheetOverlay.open {
  opacity: 1;
  pointer-events: auto;
  z-index: 1000;
  /* sits above play, below the open sheet */
}

/* Closed panel leaves a 68px "peek" (the header area) */
.bottomSheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: #111;
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.5);
  transform: translateY(calc(100% - 68px));
  transition: transform 220ms ease;
  z-index: 981;
  /* closed: below play */
  padding: 2px;
  border-top: 1px solid #222;
  overflow: visible;
}

.bottomSheet.open {
  transform: translateY(0);
  z-index: 1001;
  /* open: above overlay + play */
  background: #0f0f0f;
  /* opaque when expanded */
}

/* Clickable top of the panel; full-width tap target */
.sheetHeader {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  background: #121212;
  border: none;
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  box-shadow:
    0 -1px 0 rgba(255, 255, 255, 0.04) inset,
    0 1px 0 rgba(0, 0, 0, 0.35) inset;
  touch-action: manipulation;
}

.sheetHeader .title {
  font-size: 23px;
  letter-spacing: 0.4px;
  opacity: 0.85;
  text-transform: lowercase;
}

/* Keep header easy to tap when closed */
.bottomSheet:not(.open) .sheetHeader {
  min-height: 48px;
  padding-top: 12px;
  padding-bottom: 12px;
}

/* Optional hover affordance */
@media (hover:hover) {
  .sheetHeader:hover {
    filter: brightness(1.04);
  }
}

/* Utility */
.hidden {
  display: none !important;
}

/* QR overlay is highest z */
#qrOverlay {
  z-index: 9999 !important;
}

/* --- Dot meter under file name --- */
.file-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.dotbar {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 10px;
}

.dotbar .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #1cff8a;
  /* neon green */
  box-shadow:
    0 0 6px rgba(0, 255, 153, 0.75),
    0 0 12px rgba(0, 255, 153, 0.35);
}