/* =========================================================================
   Relay — design system
   Dark-first. Bootstrap 5 provides the component skeleton (grid, modals,
   spinners, progress); everything visual below is Relay's own. Bootstrap's
   own CSS variables are re-pointed at Relay tokens so its components inherit
   the theme instead of fighting it.
   ========================================================================= */

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('../assets/fonts/inter-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('../assets/fonts/inter-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ---------------------------------------------------------------- tokens */

:root.dark,
:root {
  --bg: #0a0c12;
  --bg-elev: #11141d;
  --surface: #151925;
  --surface-2: #1b2030;
  --surface-3: #212738;
  --border: #252b3b;
  --border-strong: #333b50;
  --text: #eef1f8;
  --text-dim: #9aa4bf;
  --text-mute: #6b7490;
  --accent: #818cf8;
  --accent-strong: #6366f1;
  --accent-2: #22d3ee;
  --accent-soft: rgba(129, 140, 248, 0.14);
  --accent-ring: rgba(129, 140, 248, 0.25);
  --success: #34d399;
  --success-soft: rgba(52, 211, 153, 0.13);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.13);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.13);
  --qr-fg: #eef1f8;

  --glow-1: rgba(99, 102, 241, 0.30);
  --glow-2: rgba(6, 182, 212, 0.20);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 24px -8px rgba(0, 0, 0, 0.55), 0 2px 6px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 24px 60px -18px rgba(0, 0, 0, 0.7), 0 8px 20px -8px rgba(0, 0, 0, 0.4);

  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 26px;

  --ease: cubic-bezier(0.32, 0.72, 0, 1);
}

:root.light {
  --bg: #f5f7fc;
  --bg-elev: #ffffff;
  --surface: #ffffff;
  --surface-2: #f4f6fb;
  --surface-3: #eceff7;
  --border: #e2e7f1;
  --border-strong: #cdd5e4;
  --text: #0d111b;
  --text-dim: #4d5772;
  --text-mute: #7c86a1;
  --accent: #4f46e5;
  --accent-strong: #4338ca;
  --accent-2: #0891b2;
  --accent-soft: rgba(79, 70, 229, 0.09);
  --accent-ring: rgba(79, 70, 229, 0.18);
  --success: #059669;
  --success-soft: rgba(5, 150, 105, 0.1);
  --warn: #b45309;
  --warn-soft: rgba(180, 83, 9, 0.1);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.09);
  --qr-fg: #0d111b;

  --glow-1: rgba(99, 102, 241, 0.16);
  --glow-2: rgba(6, 182, 212, 0.12);

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-md: 0 8px 24px -10px rgba(16, 24, 40, 0.14), 0 2px 6px rgba(16, 24, 40, 0.05);
  --shadow-lg: 0 24px 60px -20px rgba(16, 24, 40, 0.22), 0 8px 20px -10px rgba(16, 24, 40, 0.1);
}

/* Re-point Bootstrap at Relay's tokens so its components theme themselves. */
:root.dark,
:root.light,
:root {
  --bs-body-bg: var(--bg);
  --bs-body-color: var(--text);
  --bs-border-color: var(--border);
  --bs-border-radius: var(--r-md);
  --bs-primary: var(--accent-strong);
  --bs-link-color: var(--accent);
  --bs-link-hover-color: var(--accent);
  --bs-emphasis-color: var(--text);
  --bs-secondary-color: var(--text-dim);
  --bs-font-sans-serif: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ------------------------------------------------------------------ base */

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-variant-numeric: tabular-nums;
}

/* Ambient gradient field. Two soft lights, one per accent, fixed behind the
   content — carries the brand without tinting any surface. */
body::before {
  content: '';
  position: fixed;
  inset: -20vmax;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(42vmax 42vmax at 22% 8%, var(--glow-1), transparent 65%),
    radial-gradient(38vmax 38vmax at 88% 92%, var(--glow-2), transparent 62%);
  animation: drift 26s var(--ease) infinite alternate;
}

@keyframes drift {
  from { transform: translate3d(-2%, -1%, 0) scale(1); }
  to   { transform: translate3d(3%, 2%, 0) scale(1.08); }
}

@media (prefers-reduced-motion: reduce) {
  body::before { animation: none; }
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

h1, h2, h3, h4, h5 {
  color: var(--text);
  letter-spacing: -0.021em;
  font-weight: 650;
  margin: 0;
}

p { color: var(--text-dim); margin: 0 0 12px; }
p:last-child { margin-bottom: 0; }

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.15s var(--ease);
}
a:hover { color: var(--accent-2); }

hr {
  border: none;
  border-top: 1px solid var(--border);
  opacity: 1;
  margin: 22px 0;
}

code, .mono {
  font-family: 'SF Mono', ui-monospace, 'Cascadia Mono', 'Fira Code', Consolas, monospace;
  font-size: 0.92em;
}

::selection { background: var(--accent-ring); color: var(--text); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

/* --------------------------------------------------------------- top bar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px clamp(16px, 4vw, 40px);
  /* Solid first: color-mix() needs Chrome 111 / Safari 16.2, and a browser that
     skips the second declaration must still get an opaque bar, not a see-through one. */
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(14px) saturate(150%);
  -webkit-backdrop-filter: blur(14px) saturate(150%);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  cursor: pointer;
  border-radius: var(--r-md);
  padding: 4px 8px 4px 4px;
  margin-left: -4px;
  transition: background-color 0.15s var(--ease);
}
.brand:hover { background: var(--surface-2); }

.brand-tile {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 11px;
  color: #fff;
  background: linear-gradient(135deg, #6366f1, #4f46e5 55%, #06b6d4);
  box-shadow: 0 4px 14px -4px rgba(79, 70, 229, 0.7);
  flex: none;
}
.brand-tile svg { width: 22px; height: 22px; display: block; }

.brand-name {
  font-size: 1.2rem;
  font-weight: 750;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--text);
}

.app-version {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-mute);
  padding: 2px 7px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  white-space: nowrap;
}
.app-version:empty { display: none; }

.topbar-spacer { flex: 1 1 auto; }

/* Both of these have their text swapped by JS, so they must stay plain-text
   elements — the pill styling lives on the element itself. */
.pill-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 66px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 550;
  color: var(--text-dim);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  user-select: none;
  transition: color 0.15s var(--ease), background-color 0.15s var(--ease),
              border-color 0.15s var(--ease), transform 0.15s var(--ease);
}
.pill-btn:hover {
  color: var(--text);
  background: var(--surface-3);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

/* ----------------------------------------------------------------- shell */

.shell {
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  padding: clamp(28px, 6vh, 56px) clamp(16px, 4vw, 24px) 64px;
}

/* ------------------------------------------------------------------ hero */

.hero { text-align: center; margin-bottom: 34px; }

.hero h1 {
  font-size: clamp(1.9rem, 1.2rem + 2.6vw, 3rem);
  font-weight: 760;
  letter-spacing: -0.035em;
  line-height: 1.08;
  margin-bottom: 14px;
}

.hero h1 .grad {
  background: linear-gradient(100deg, var(--accent) 10%, var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.lede {
  font-size: clamp(0.98rem, 0.9rem + 0.3vw, 1.1rem);
  color: var(--text-dim);
  max-width: 46ch;
  margin: 0 auto;
}

.hero-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 22px 0 0;
  padding: 0;
  list-style: none;
}

.hero-badges li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 13px 6px 10px;
  font-size: 12.5px;
  font-weight: 550;
  color: var(--text-dim);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.hero-badges svg { width: 14px; height: 14px; flex: none; color: var(--accent); }

/* ---------------------------------------------------------------- panels */

.panel {
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: clamp(18px, 3vw, 28px);
  box-shadow: var(--shadow-md);
  text-align: left;
  animation: rise 0.45s var(--ease) both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}

.panel + .panel { margin-top: 18px; }

.panel-status {
  display: flex;
  align-items: center;
  gap: 11px;
  font-size: 15px;
  font-weight: 550;
  color: var(--text);
}

.panel-danger { border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); }
.panel-danger .panel-status { color: var(--danger); }
.panel-danger svg { color: var(--danger); flex: none; }

/* ------------------------------------------------------------ room / QR */

.room {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(18px, 3vw, 30px);
  align-items: flex-start;
}

/* White in both themes on purpose: phone cameras read dark-on-light codes far
   more reliably than inverted ones, so the tile stays a light card even in dark
   mode rather than following the surface token. */
.qr-frame {
  flex: none;
  padding: 12px;
  border-radius: var(--r-lg);
  background: #fff;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  line-height: 0;
}
.qr-frame canvas { display: block; width: 168px; height: 168px; }

.room-main { flex: 1 1 320px; min-width: 260px; }

/* Live status line above the room URL. */
.status-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
  min-height: 26px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.005em;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.chip svg { width: 14px; height: 14px; flex: none; }
.chip-wait    { color: var(--text-dim); background: var(--surface-2); border-color: var(--border); }
.chip-live    { color: var(--success); background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 35%, transparent); }
.chip-locked  { color: var(--accent); background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }

/* Pulsing dot for the "live" chip. */
.live-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--success) 60%, transparent);
  animation: pulse 2s var(--ease) infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--success) 55%, transparent); }
  70%  { box-shadow: 0 0 0 8px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

.field-label {
  display: block;
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-mute);
  margin-bottom: 7px;
}

/* Click-to-copy room link. */
.copy-row {
  display: flex;
  align-items: stretch;
  gap: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface-2);
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.copy-row:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.copy-value {
  flex: 1 1 auto;
  min-width: 0;
  padding: 12px 14px;
  font-family: 'SF Mono', ui-monospace, 'Cascadia Mono', 'Fira Code', Consolas, monospace;
  font-size: 13.5px;
  color: var(--accent);
  word-break: break-all;
  line-height: 1.45;
  background: none;
  border: none;
}

.copy-action {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 46px;
  color: var(--text-dim);
  background: var(--surface-3);
  border-left: 1px solid var(--border);
  transition: color 0.15s var(--ease);
}
.copy-row:hover .copy-action { color: var(--text); }
.copy-action svg { width: 16px; height: 16px; }
#transfer-url-success { color: var(--success); }

.room-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.hint {
  font-size: 12.5px;
  color: var(--text-mute);
  margin: 14px 0 0;
}

/* --------------------------------------------------------------- buttons */

.btn {
  --btn-bg: var(--surface-2);
  --btn-fg: var(--text);
  --btn-bd: var(--border-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--btn-fg);
  background: var(--btn-bg);
  border: 1px solid var(--btn-bd);
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.15s var(--ease), box-shadow 0.15s var(--ease),
              filter 0.15s var(--ease), background-color 0.15s var(--ease);
}
.btn svg { width: 17px; height: 17px; flex: none; }
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.btn-primary {
  --btn-fg: #fff;
  --btn-bd: transparent;
  background: linear-gradient(135deg, #6366f1, #4f46e5 60%, #0ea5e9);
  box-shadow: 0 6px 20px -8px rgba(79, 70, 229, 0.85);
}
.btn-primary:hover { filter: brightness(1.08); box-shadow: 0 10px 26px -8px rgba(79, 70, 229, 0.95); }

.btn-success {
  --btn-fg: var(--success);
  --btn-bg: var(--success-soft);
  --btn-bd: color-mix(in srgb, var(--success) 40%, transparent);
}
.btn-success:hover { --btn-bg: color-mix(in srgb, var(--success) 20%, transparent); }

.btn-secondary { --btn-bg: var(--surface-2); --btn-fg: var(--text-dim); }
.btn-secondary:hover { --btn-bg: var(--surface-3); --btn-fg: var(--text); }

.btn-danger {
  --btn-fg: var(--danger);
  --btn-bg: var(--danger-soft);
  --btn-bd: color-mix(in srgb, var(--danger) 40%, transparent);
}
.btn-danger:hover { --btn-bg: color-mix(in srgb, var(--danger) 20%, transparent); }

.btn-lg { padding: 14px 26px; font-size: 15.5px; }
.btn-block { width: 100%; }

/* ------------------------------------------------------------------ list */

/* Bootstrap .card / .list-group keep their classes (the app's JS appends
   .list-group-item rows), restyled here as Relay "stacks". */
.card {
  margin-top: 16px;
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--r-lg) !important;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.card .card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 18px !important;
  background: var(--surface-2) !important;
  border-bottom: 1px solid var(--border) !important;
  color: var(--text) !important;
  font-size: 12px !important;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.card-header-title { display: inline-flex; align-items: baseline; gap: 5px; }
.card-header-title .count { color: var(--text-mute); font-weight: 600; }
.card-header-grow { flex: 1 1 auto; }

.card .card-header .card-header-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0.04em;
  color: var(--text-dim) !important;
  cursor: pointer;
  padding: 4px 9px;
  margin: -4px -4px -4px 0;
  border-radius: 999px;
  transition: color 0.15s var(--ease), background-color 0.15s var(--ease);
}
.card .card-header .card-header-action:hover {
  color: var(--text) !important;
  background: var(--surface-3);
}
.card-header-action svg { width: 13px; height: 13px; flex: none; }

.card .list-group { border-radius: 0; }

.card .list-group-item {
  padding: 13px 18px !important;
  background: transparent !important;
  border: none !important;
  border-top: 1px solid var(--border) !important;
  color: var(--text) !important;
  font-size: 14px;
  transition: background-color 0.15s var(--ease);
}
.card .list-group-item:first-child { border-top: none !important; }
.card .list-group-item:hover { background: var(--surface-2) !important; }

/* User rows: mark + name. */
#transfer-users-list .list-group-item,
#transfer-users-list-host {
  display: flex;
  align-items: center;
  gap: 10px;
}
#transfer-users-list svg { width: 15px; height: 15px; flex: none; }

.empty-row {
  color: var(--text-mute) !important;
  font-size: 13.5px !important;
}

/* File rows are built in JS; these classes carry their look. */
.file-icon { display: flex; align-items: center; justify-content: center; width: 22px; flex: none; }
.file-name {
  display: flex;
  align-items: center;
  gap: 2px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  word-break: break-all;
  margin-bottom: 3px;
}
.file-name svg { width: 16px; height: 16px; flex: none; color: var(--text-mute); }
.file-meta { font-size: 12.5px; font-weight: 500; color: var(--text-mute); }
.file-error { font-size: 12.5px; font-weight: 500; color: var(--danger); margin-top: 5px; }
.file-details {
  display: inline-block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  margin-top: 6px;
}
.file-details:hover { color: var(--accent-2); }
.file-action { cursor: pointer; display: flex; align-items: center; }
.file-action svg { width: 22px; height: 22px; }

/* ---------------------------------------------------------- drag & drop */

.dropzone {
  margin-top: 18px;
  padding: 26px 20px;
  text-align: center;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--r-lg);
  color: var(--text-mute);
  font-size: 13.5px;
  background: var(--surface-2);
  background: color-mix(in srgb, var(--surface-2) 50%, transparent);
  transition: border-color 0.2s var(--ease), color 0.2s var(--ease), background-color 0.2s var(--ease);
}
.dropzone svg { width: 22px; height: 22px; display: block; margin: 0 auto 8px; opacity: 0.7; }

#transfer-div.drag-over {
  border-color: var(--accent);
  box-shadow: var(--shadow-md), 0 0 0 4px var(--accent-ring);
}
#transfer-div.drag-over .dropzone {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}
#transfer-div.drag-over .dropzone svg { opacity: 1; }

/* ------------------------------------------------------------------ form */

.form-control,
input.form-control,
#name-modal-value,
#password-input,
#password-modal-value {
  width: 100%;
  padding: 11px 14px !important;
  font-family: inherit !important;
  font-size: 14.5px !important;
  color: var(--text) !important;
  background: var(--surface-2) !important;
  border: 1px solid var(--border-strong) !important;
  border-radius: var(--r-sm) !important;
  box-shadow: none !important;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.form-control::placeholder { color: var(--text-mute); }
.form-control:focus {
  outline: none;
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px var(--accent-ring) !important;
}

/* Password field + reveal toggle. */
.input-row { display: flex; align-items: stretch; }
.input-row .form-control {
  border-top-right-radius: 0 !important;
  border-bottom-right-radius: 0 !important;
  border-right-color: transparent !important;
}
.reveal-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 46px;
  color: var(--text-dim);
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  border-left: none;
  border-top-right-radius: var(--r-sm);
  border-bottom-right-radius: var(--r-sm);
  cursor: pointer;
  transition: color 0.15s var(--ease), background-color 0.15s var(--ease);
}
.reveal-btn:hover { color: var(--text); background: var(--surface-2); }
.reveal-btn svg { width: 18px; height: 18px; }

.form-error {
  display: none;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  font-size: 12.5px;
  font-weight: 550;
  color: var(--danger);
}
.form-error svg { width: 13px; height: 13px; flex: none; }

label { font-size: 13px; font-weight: 600; color: var(--text-dim); }

/* ----------------------------------------------------------------- alert */

.alert {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 14px;
  margin-bottom: 14px;
  font-size: 13.5px;
  font-weight: 550;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
}
.alert-danger {
  color: var(--danger) !important;
  background: var(--danger-soft) !important;
  border-color: color-mix(in srgb, var(--danger) 35%, transparent) !important;
}
.alert svg { width: 15px; height: 15px; flex: none; }
.alert .btn-close { margin-left: auto; }

/* ---------------------------------------------------------------- modals */

.modal-content {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--r-lg) !important;
  box-shadow: var(--shadow-lg) !important;
}

.modal-header {
  align-items: center;
  gap: 10px;
  padding: 17px 22px !important;
  border-bottom: 1px solid var(--border) !important;
}
.modal-header h5 {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 1rem;
  font-weight: 650;
  color: var(--text) !important;
}
.modal-header h5 svg { width: 17px; height: 17px; flex: none; color: var(--accent); }

.modal-body { padding: 20px 22px !important; }
.modal-footer {
  gap: 8px;
  padding: 15px 22px !important;
  border-top: 1px solid var(--border) !important;
}
.modal-backdrop.show { opacity: 0.6; }
.btn-close { filter: none; opacity: 0.5; }
:root.dark .btn-close { filter: invert(1) grayscale(1) brightness(2); }
.btn-close:hover { opacity: 0.9; }

/* ---------------------------------------------------------------- tables */

.table {
  margin: 0;
  color: var(--text) !important;
  font-size: 13.5px;
  --bs-table-bg: transparent;
  --bs-table-color: var(--text);
  --bs-table-hover-bg: var(--surface-2);
  --bs-table-hover-color: var(--text);
}

.table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  margin-bottom: 18px;
}

.table thead th {
  padding: 10px 15px !important;
  font-size: 10.5px !important;
  font-weight: 700 !important;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-mute) !important;
  background: var(--surface-2) !important;
  border-bottom: 1px solid var(--border) !important;
  border-top: none !important;
}

.table td {
  padding: 11px 15px !important;
  vertical-align: middle;
  border-color: var(--border) !important;
}
.table tbody tr:last-child td { border-bottom: none !important; }

.status-badge {
  display: inline-block;
  padding: 3px 10px;
  font-size: 11.5px;
  font-weight: 650;
  border-radius: 999px;
}
.online-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; }

/* --------------------------------------------------------- progress bars */

.progress {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-3) !important;
  overflow: hidden;
}
.progress-bar {
  background: linear-gradient(90deg, var(--accent-strong), var(--accent-2)) !important;
  border-radius: 999px;
  transition: width 0.35s var(--ease);
}
.progress-bar.bg-success { background: var(--success) !important; }
.progress-bar.bg-danger  { background: var(--danger) !important; }

.progress-tall { height: 12px; }

.metric {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* -------------------------------------------------------------- spinners */

.spinner-border {
  width: 1.05rem;
  height: 1.05rem;
  --bs-spinner-border-width: 0.12em;
  color: var(--accent);
  flex: none;
}

/* ----------------------------------------------------------------- about */

.about-steps {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
  margin: 20px 0 6px;
  padding: 0;
  list-style: none;
  counter-reset: step;
}
@media (min-width: 720px) {
  .about-steps { grid-template-columns: repeat(3, 1fr); }
}

.about-steps li {
  position: relative;
  padding: 16px 16px 16px 18px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.about-steps li::before {
  counter-increment: step;
  content: counter(step);
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  margin-bottom: 10px;
  font-size: 11.5px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--accent-strong), var(--accent-2));
  border-radius: 999px;
}
.about-steps strong { display: block; font-size: 14px; color: var(--text); margin-bottom: 3px; }
.about-steps span { font-size: 12.5px; color: var(--text-dim); line-height: 1.55; }

.section-title {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 28px 0 12px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-mute);
}
.section-title svg { width: 15px; height: 15px; color: var(--accent); flex: none; }

.about-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text-mute);
}

/* Flow panels (error / connecting / password / room) while an overlay is open.
   user.js flips their inline display as the connection state changes; this keeps
   those changes from surfacing underneath About or History, without having to
   intercept every such assignment. Closing the overlay drops the class and the
   inline state — which is still the correct one — applies again. */
body.overlay-open .panel-flow { display: none !important; }

/* --------------------------------------------------------------- history */

.history-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.history-head .btn { padding: 8px 16px; font-size: 13.5px; }
.history-head .btn svg { width: 14px; height: 14px; }

/* Empty / unavailable states. JS toggles these to 'flex'. */
.history-note {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  padding: 34px 20px;
  color: var(--text-mute);
  background: var(--surface-2);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-md);
}
.history-note svg { opacity: 0.45; }
.history-note p { margin: 0; font-size: 13.5px; max-width: 44ch; color: var(--text-mute); }

.history-list {
  margin: 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
}
.history-list:empty { display: none; }

.history-row {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  transition: background-color 0.15s var(--ease);
}
.history-row:first-child { border-top: none; }
.history-row:hover { background: var(--surface-3); }

.history-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 9px;
}
.history-icon svg { width: 16px; height: 16px; }
.history-icon-sent     { color: var(--accent);  background: var(--accent-soft); }
.history-icon-received { color: var(--success); background: var(--success-soft); }

.history-body { flex: 1 1 auto; min-width: 0; }

.history-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.history-meta {
  font-size: 12.5px;
  color: var(--text-mute);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-row .status-badge { flex: none; }

@media (max-width: 560px) {
  .history-row .status-badge { display: none; }
  .history-head .btn { width: 100%; }
}

/* ----------------------------------------------------------------- toast */

#notification-toast {
  position: fixed;
  top: 18px;
  left: 50%;
  z-index: 9999;
  transform: translateX(-50%) translateY(-120px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.4s var(--ease), opacity 0.3s ease;
}
.toast-body {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 18px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
}
.toast-body svg { width: 17px; height: 17px; flex: none; }

/* ---------------------------------------------------------------- footer */

.site-footer {
  margin-top: 40px;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-mute);
}
.site-footer p {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: inherit;
  margin: 0;
}
.site-footer svg { width: 13px; height: 13px; opacity: 0.7; }

/* ------------------------------------------------------------- scrollbar */

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 999px;
  border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--text-mute); }

/* -------------------------------------------------------------- narrow */

@media (max-width: 560px) {
  .topbar { padding: 12px 16px; gap: 8px; }
  .brand-name { font-size: 1.08rem; }
  .pill-btn { min-width: 0; padding: 7px 12px; }
  .room { flex-direction: column; align-items: center; }
  .qr-frame { align-self: center; }
  .qr-frame canvas { width: 150px; height: 150px; }
  .room-main { width: 100%; }
  .room-actions .btn { width: 100%; }
}
