/* =======================================================
   Stream Companion — Base
   ======================================================= */

:root {
  color-scheme: dark;

  --page-bg: #17131f;
  --panel-bg: rgba(39, 35, 59, 0.96);
  --panel-bg-soft: rgba(31, 28, 47, 0.94);

  --border: rgba(122, 92, 255, 0.28);
  --border-strong: rgba(122, 92, 255, 0.52);

  --text: #f5f3ff;
  --text-soft: #b8b2ca;
  --text-muted: #8d879d;

  --accent: #7a5cff;
  --accent-hover: #8d75ff;

  --live: #ff4c62;
  --success: #52d273;

  --radius: 14px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(
      circle at top left,
      rgba(122, 92, 255, 0.16),
      transparent 34rem
    ),
    var(--page-bg);
  color: var(--text);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled,
input:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

a {
  color: inherit;
}

h1,
h2,
p {
  margin-top: 0;
}


/* =======================================================
   Main Shell
   ======================================================= */

.stream-app {
  width: min(1480px, calc(100% - 32px));
  margin: 0 auto;
  padding: 16px 0 18px;
}


/* =======================================================
   Header
   ======================================================= */

.stream-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.stream-brand-label,
.section-label {
  margin-bottom: 6px;
  color: var(--accent-hover);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.stream-header h1 {
  margin-bottom: 4px;
  font-size: clamp(1.9rem, 4vw, 3.2rem);
  line-height: 1;
}

.stream-description {
  margin-bottom: 0;
  color: var(--text-soft);
  font-size: 0.95rem;
}

.stream-status {
  display: flex;
  gap: 9px;
  align-items: center;
  flex: 0 0 auto;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(20, 18, 30, 0.75);
  color: var(--text-soft);
  font-size: 0.86rem;
}

.live-status-indicator {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--text-muted);
}

.stream-status.is-live .live-status-indicator {
  background: var(--live);
  box-shadow: 0 0 12px rgba(255, 76, 98, 0.72);
}


/* =======================================================
   Shared Panels
   ======================================================= */

.streamer-card,
.video-panel,
.chat-panel,
.zap-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel-bg);
  box-shadow: var(--shadow);
}

.panel-heading,
.zap-heading {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
}

.panel-heading h2,
.zap-heading h2,
.streamer-details h2 {
  margin-bottom: 0;
  font-size: 1.2rem;
}


/* =======================================================
   Streamer Card
   ======================================================= */

.streamer-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  margin-bottom: 14px;
  padding: 10px 16px;
}

.streamer-avatar-shell {
  width: 50px;
  height: 50px;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background: var(--panel-bg-soft);
}

.streamer-avatar,
.streamer-avatar-fallback {
  width: 100%;
  height: 100%;
}

.streamer-avatar {
  display: block;
  object-fit: cover;
}

.streamer-avatar-fallback {
  display: grid;
  place-items: center;
  color: white;
  font-size: 1.25rem;
  font-weight: 800;
  background:
    linear-gradient(
      135deg,
      rgba(122, 92, 255, 0.85),
      rgba(68, 45, 169, 0.92)
    );
}

.streamer-details {
  min-width: 0;
}

.streamer-npub {
  overflow: hidden;
  margin: 5px 0 0;
  color: var(--text-muted);
  font-family:
    "SFMono-Regular",
    Consolas,
    "Liberation Mono",
    monospace;
  font-size: 0.82rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.identity-button,
.chat-form button,
.custom-zap-controls button,
.zap-amount-button {
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--accent);
  color: white;
  font-weight: 700;
  transition:
    transform 120ms ease,
    background 120ms ease,
    border-color 120ms ease;
}

.identity-button {
  padding: 10px 16px;
}

.identity-button:hover:not(:disabled),
.chat-form button:hover:not(:disabled),
.custom-zap-controls button:hover:not(:disabled),
.zap-amount-button:hover:not(:disabled) {
  transform: translateY(-1px);
  background: var(--accent-hover);
}


/* =======================================================
   Workspace
   ======================================================= */

.stream-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(320px, 0.8fr);
  gap: 16px;
  align-items: stretch;
}

.video-panel,
.chat-panel {
  min-width: 0;
  padding: 16px;
}


/* =======================================================
   Video
   ======================================================= */

.external-stream-link {
  color: var(--accent-hover);
  font-size: 0.86rem;
  font-weight: 700;
  text-decoration: none;
}

.external-stream-link:hover {
  text-decoration: underline;
}

.rumble-player-shell {
  position: relative;
  overflow: hidden;
  width: 100%;
  margin-top: 14px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  background: #0c0a12;
  aspect-ratio: 16 / 9;
}

.rumble-player,
.video-placeholder {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.rumble-player {
  border: 0;
}

.video-placeholder {
  display: grid;
  place-content: center;
  padding: 24px;
  color: var(--text-muted);
  text-align: center;
  background:
    radial-gradient(
      circle at center,
      rgba(122, 92, 255, 0.13),
      transparent 45%
    ),
    #0c0a12;
}

.video-placeholder-title {
  margin-bottom: 8px;
  color: var(--text-soft);
  font-size: 1.25rem;
  font-weight: 800;
}


/* =======================================================
   Chat
   ======================================================= */

.chat-panel {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(300px, 1fr) auto auto;
  min-height: 0;
}

.relay-status {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.relay-status.is-connected {
  color: var(--success);
}

.relay-status.connecting {
    color: #d7c66c;
}

.relay-status.loading {
    color: #d7c66c;
}

.relay-status.live {
    color: #6adf8d;
}

.relay-status.error {
    color: #ff7d7d;
}

.chat-messages {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  min-height: 300px;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  background: rgba(17, 15, 27, 0.72);
}

.chat-messages > :first-child {
  margin-top: auto;
}

.empty-chat-message {
  display: grid;
  place-content: center;
  min-height: 100%;
  color: var(--text-muted);
  text-align: center;
}

.empty-chat-message p:last-child {
  margin-bottom: 0;
}

.chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  margin-top: 12px;
}

.chat-form textarea,
.custom-zap-controls input,
#zapMessage {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  background: rgba(14, 12, 23, 0.88);
  color: var(--text);
}

.chat-form textarea {
  min-height: 46px;
  max-height: 140px;
  padding: 10px 12px;
  resize: vertical;
}

.chat-form button {
  min-width: 100px;
  padding: 0 16px;
}

.chat-form textarea:focus,
.custom-zap-controls input:focus,
#zapMessage:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(122, 92, 255, 0.14);
}

.chat-status,
.zap-status {
  min-height: 1.25em;
  margin: 8px 0 0;
  color: var(--text-muted);
  font-size: 0.8rem;
}


/* =======================================================
   Zap Panel
   ======================================================= */

.zap-panel {
  margin-top: 18px;
  padding: 16px;
}

.lightning-address {
  margin-bottom: 0;
  color: var(--text-muted);
  font-family:
    "SFMono-Regular",
    Consolas,
    "Liberation Mono",
    monospace;
  font-size: 0.82rem;
}

.zap-amount-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 16px 0;
}

.zap-amount-button {
  padding: 10px 15px;
}

.custom-zap {
  margin-bottom: 14px;
}

.custom-zap label,
.zap-panel > label {
  display: block;
  margin-bottom: 7px;
  color: var(--text-soft);
  font-size: 0.84rem;
  font-weight: 700;
}

.custom-zap-controls {
  display: grid;
  grid-template-columns: minmax(0, 220px) auto;
  gap: 10px;
}

.custom-zap-controls input,
#zapMessage {
  padding: 10px 12px;
}

.custom-zap-controls button {
  padding: 10px 15px;
}


/* =======================================================
   Footer and Accessibility
   ======================================================= */

.stream-footer {
  padding: 18px 0 4px;
  color: var(--text-muted);
  font-size: 0.78rem;
  text-align: center;
}

.stream-footer p {
  margin-bottom: 0;
}

.visually-hidden {
  position: absolute !important;
  overflow: hidden !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}


/* =====================================================
   Stream Configuration
   ===================================================== */

.configure-stream-button {
  margin-top: 8px;
  padding: 9px 14px;

  border: 1px solid rgba(138, 104, 255, 0.55);
  border-radius: 10px;

  background:
    rgba(138, 104, 255, 0.16);

  color: #f5f2ff;

  font: inherit;
  font-weight: 700;

  cursor: pointer;
}

.configure-stream-button:hover {
  background:
    rgba(138, 104, 255, 0.28);
}

.configure-stream-dialog {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);

  padding: 0;

  border: 1px solid
    rgba(138, 104, 255, 0.48);

  border-radius: 16px;

  background:
    rgba(24, 21, 39, 0.98);

  color: #f5f2ff;

  box-shadow:
    0 24px 70px
    rgba(0, 0, 0, 0.6);

  overflow: auto;
}

.configure-stream-dialog::backdrop {
  background:
    rgba(8, 6, 16, 0.76);

  backdrop-filter:
    blur(4px);
}

.identity-connection-dialog {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);

  padding: 0;

  border: 1px solid
    rgba(138, 104, 255, 0.48);

  border-radius: 16px;

  background:
    rgba(24, 21, 39, 0.98);

  color: #f5f2ff;

  box-shadow:
    0 24px 70px
    rgba(0, 0, 0, 0.6);

  overflow: auto;
}

.identity-connection-dialog::backdrop {
  background:
    rgba(8, 6, 16, 0.76);

  backdrop-filter:
    blur(4px);
}

.identity-connection-content {
  display: grid;
  gap: 16px;

  padding: 24px;
}

.identity-connection-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.identity-connection-heading h2 {
  margin: 4px 0 0;

  font-size: 1.45rem;
}

.identity-connection-close {
  width: 38px;
  height: 38px;

  flex: 0 0 auto;

  border: 1px solid
    rgba(255, 255, 255, 0.12);

  border-radius: 10px;

  background:
    rgba(255, 255, 255, 0.06);

  color: #f5f2ff;

  font-size: 1.4rem;
  line-height: 1;

  cursor: pointer;
}

.identity-connection-close:hover {
  background:
    rgba(255, 255, 255, 0.12);
}

.identity-connection-message,
.remote-signer-status {
  margin: 0;

  color: #d8d1ee;

  font-size: 0.94rem;
}

.identity-connection-choices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.identity-connection-choice {
  min-height: 90px;
  padding: 16px;

  border: 1px solid
    rgba(138, 104, 255, 0.42);

  border-radius: 12px;

  background:
    rgba(10, 8, 20, 0.64);

  color: #f5f2ff;

  text-align: left;

  cursor: pointer;
}

.identity-connection-choice:hover:not(:disabled),
.identity-connection-choice:focus-visible {
  background:
    rgba(138, 104, 255, 0.18);

  border-color:
    rgba(138, 104, 255, 0.72);
}

.identity-connection-choice span {
  display: block;

  margin-bottom: 8px;

  font-weight: 800;
}

.identity-connection-choice small {
  color: #b8b2ca;

  font-size: 0.82rem;
}

.remote-signer-connection-panel {
  display: grid;
  gap: 12px;
}

.remote-signer-connection-panel[hidden] {
  display: none;
}

.remote-signer-debug-indicator {
  padding: 9px 12px;

  border: 1px solid
    rgba(255, 213, 97, 0.58);

  border-radius: 10px;

  background:
    rgba(255, 213, 97, 0.14);

  color: #ffe7a6;

  font-size: 0.82rem;
  font-weight: 900;
  letter-spacing: 0;
  text-align: center;
}

.remote-signer-debug-indicator[hidden] {
  display: none;
}

.remote-signer-qr {
  display: grid;
  place-items: center;

  width: 260px;
  min-height: 260px;
  max-width: 100%;

  padding: 10px;

  border: 1px solid
    rgba(255, 255, 255, 0.12);

  border-radius: 12px;

  background:
    #fff;

  color: #332b4d;

  justify-self: center;
  text-align: center;
}

.remote-signer-qr canvas,
.remote-signer-qr img {
  display: block;

  max-width: 100%;
  height: auto;
}

.copy-remote-signer-uri-button,
.identity-connection-actions button {
  padding: 10px 14px;

  border: 1px solid
    rgba(138, 104, 255, 0.55);

  border-radius: 10px;

  background:
    rgba(138, 104, 255, 0.16);

  color: #f5f2ff;

  font: inherit;
  font-weight: 700;

  cursor: pointer;
}

.copy-remote-signer-uri-button:hover:not(:disabled),
.identity-connection-actions button:hover:not(:disabled) {
  background:
    rgba(138, 104, 255, 0.28);
}

.remote-signer-uri {
  width: 100%;
  padding: 11px 12px;

  border: 1px solid
    rgba(138, 104, 255, 0.3);

  border-radius: 10px;

  outline: none;

  background:
    rgba(10, 8, 20, 0.82);

  color: #f5f2ff;

  font-family:
    "SFMono-Regular",
    Consolas,
    "Liberation Mono",
    monospace;
  font-size: 0.78rem;

  text-overflow: ellipsis;
}

.remote-signer-diagnostics {
  padding: 10px 12px;

  border: 1px solid
    rgba(138, 104, 255, 0.28);

  border-radius: 12px;

  background:
    rgba(10, 8, 20, 0.56);
}

.remote-signer-diagnostics[hidden] {
  display: none;
}

.remote-signer-diagnostics summary {
  color: #f5f2ff;

  font-weight: 800;

  cursor: pointer;
}

.remote-signer-diagnostics-summary {
  margin-top: 10px;

  color: #b8b2ca;

  font-size: 0.84rem;
}

.remote-signer-diagnostics-list {
  display: grid;
  gap: 8px;

  max-height: 220px;
  margin: 10px 0 0;
  padding-left: 1.25rem;

  overflow-y: auto;

  color: #f5f2ff;

  font-family:
    "SFMono-Regular",
    Consolas,
    "Liberation Mono",
    monospace;
  font-size: 0.76rem;
}

.remote-signer-diagnostics-list li span,
.remote-signer-diagnostics-list li small {
  display: block;
}

.remote-signer-diagnostics-list li small {
  margin-top: 2px;

  overflow-wrap: anywhere;

  color: #b8b2ca;
}

.copy-remote-signer-diagnostics-button {
  margin-top: 10px;
  padding: 9px 12px;

  border: 1px solid
    rgba(138, 104, 255, 0.55);

  border-radius: 10px;

  background:
    rgba(138, 104, 255, 0.16);

  color: #f5f2ff;

  font: inherit;
  font-weight: 700;

  cursor: pointer;
}

.copy-remote-signer-diagnostics-button:hover:not(:disabled) {
  background:
    rgba(138, 104, 255, 0.28);
}

.identity-connection-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

@media (max-width: 560px) {
  .identity-connection-content {
    padding: 20px;
  }

  .identity-connection-choices {
    grid-template-columns: 1fr;
  }

  .remote-signer-qr {
    width: 240px;
    min-height: 240px;
  }

  .copy-remote-signer-uri-button,
  .copy-remote-signer-diagnostics-button,
  .identity-connection-actions button {
    width: 100%;
  }
}

.configure-stream-form {
  display: grid;
  gap: 10px;

  padding: 24px;
}

.configure-stream-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;

  margin-bottom: 8px;
}

.configure-stream-heading h2 {
  margin: 4px 0 0;

  font-size: 1.6rem;
}

.configure-stream-close {
  width: 38px;
  height: 38px;

  flex: 0 0 auto;

  border: 1px solid
    rgba(255, 255, 255, 0.12);

  border-radius: 10px;

  background:
    rgba(255, 255, 255, 0.06);

  color: #f5f2ff;

  font-size: 1.4rem;
  line-height: 1;

  cursor: pointer;
}

.configure-stream-close:hover {
  background:
    rgba(255, 255, 255, 0.12);
}

.configure-stream-form label {
  margin-top: 5px;

  color: #d8d1ee;

  font-size: 0.92rem;
  font-weight: 700;
}

.configure-stream-form input,
.configure-stream-form select,
.configure-stream-form textarea {
  width: 100%;
  box-sizing: border-box;

  padding: 11px 12px;

  border: 1px solid
    rgba(138, 104, 255, 0.3);

  border-radius: 10px;

  background:
    rgba(10, 8, 20, 0.82);

  color: #f5f2ff;

  font: inherit;
}

.configure-stream-form textarea {
  resize: vertical;
  min-height: 88px;
}

.configure-stream-form input:focus,
.configure-stream-form select:focus,
.configure-stream-form textarea:focus {
  outline: 2px solid
    rgba(138, 104, 255, 0.75);

  outline-offset: 1px;

  border-color:
    rgba(138, 104, 255, 0.75);
}

.configure-stream-status {
  min-height: 1.4em;
  margin: 4px 0 0;

  color: #cfc6ed;

  font-size: 0.9rem;
}

.configure-stream-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;

  margin-top: 10px;
}

.configure-stream-actions button {
  padding: 10px 16px;

  border-radius: 10px;

  font: inherit;
  font-weight: 700;

  cursor: pointer;
}

#cancelConfigureStreamButton {
  border: 1px solid
    rgba(255, 255, 255, 0.14);

  background:
    rgba(255, 255, 255, 0.06);

  color: #f5f2ff;
}

#saveStreamConfigurationButton {
  border: 1px solid
    rgba(138, 104, 255, 0.7);

  background:
    rgba(112, 76, 230, 0.82);

  color: #ffffff;
}

#saveStreamConfigurationButton:hover {
  background:
    rgba(126, 88, 245, 0.95);
}

#startNewStreamButton {
  width: 100%;
}

@media (max-width: 600px) {
  .configure-stream-dialog {
    width: calc(100vw - 20px);
    max-height: calc(100vh - 20px);

    border-radius: 14px;
  }

  @media (max-width: 700px) {
    .custom-zap-controls {
      grid-template-columns: 1fr;
    }

    .zap-payment {
      grid-template-columns: 140px 1fr;
    }

    .zap-qr-code,
    .zap-qr-code canvas,
    .zap-qr-code img {
      width: 140px !important;
      height: 140px !important;
    }
  }

  .configure-stream-form {
    padding: 18px;
  }

  .configure-stream-actions {
    flex-direction: column-reverse;
  }

  .configure-stream-actions button {
    width: 100%;
  }

  .current-stream-details {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin: 0.75rem 0 1rem;
  }

  .current-stream-label {
    font-size: .82rem;
    opacity: .65;
  }

  #currentStreamStarted {
    font-size: 1rem;
  }

  .configure-stream-section {
    margin-top: 2rem;
    padding-top: 1.25rem;
    border-top: 1px solid rgba(255,255,255,.12);
  }

  .current-stream-help {
    margin: 0;
    font-size: 0.85rem;
    color: rgba(255,255,255,.65);
    line-height: 1.4;
  }
}

/* =======================================================
   Responsive
   ======================================================= */

@media (max-width: 900px) {
  .stream-workspace {
    grid-template-columns: 1fr;
  }

  .chat-panel {
    min-height: 500px;
  }
}

@media (max-width: 640px) {
  .stream-app {
    width: min(100% - 20px, 1480px);
    padding-top: 14px;
  }

  .stream-header {
    display: grid;
  }

  .stream-status {
    justify-self: start;
  }

  .streamer-card {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .identity-button {
    grid-column: 1 / -1;
    width: 100%;
  }

  .panel-heading,
  .zap-heading {
    align-items: flex-start;
  }

  .chat-panel {
    min-height: 460px;
  }

  .chat-form {
    grid-template-columns: 1fr;
  }

  .chat-form button {
    min-height: 42px;
    min-width: 100px;
  }

  .custom-zap-controls {
    display: grid;
    grid-template-columns:
      minmax(180px, 275px)
      minmax(0, 1fr);
    gap: 12px;
    align-items: end;
  }

  .zap-action-column {
    display: grid;
    gap: 12px;
  }

  .zap-payment {
    display: grid;
    grid-template-columns:
      160px
      minmax(0, 1fr);
    grid-template-areas:
      "qr summary"
      "qr actions";
    gap: 10px 16px;
    align-items: center;

    padding: 12px;

    border: 1px solid
      rgba(122, 92, 255, 0.3);

    border-radius: 12px;

    background:
      rgba(17, 14, 29, 0.6);
  }

  .zap-payment-actions {
    grid-area: actions;

    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  .zap-payment[hidden] {
    display: none;
  }

  #zapPaymentSummary {
    grid-area: summary;
    margin: 0;
  }

  #customZapButton {
    width: 100%;
  }

  .zap-qr-code {
    grid-area: qr;
    width: 160px;
    height: 160px;
  }

  .zap-qr-code canvas,
  .zap-qr-code img {
    display: block;

    width: 160px !important;
    height: 160px !important;
  }


  .zap-amount-buttons {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .zap-amount-button {
    width: 100%;
  }

  .lightning-address {
    max-width: 48%;
    overflow-wrap: anywhere;
    text-align: right;
  }
}

.viewer-identity {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.viewer-avatar {
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid rgba(122, 92, 255, 0.5);
}

.viewer-avatar[hidden] {
  display: none;
}

.viewer-identity-copy {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.nostr-connect-button {
  appearance: none;
  border: 0;
  border-radius: 12px;
  padding: 12px 20px;
  background: linear-gradient(
    135deg,
    #8d63ff,
    #6f45f5
  );
  color: #ffffff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  box-shadow:
    0 8px 24px rgba(111, 69, 245, 0.24);
  transition:
    transform 140ms ease,
    box-shadow 140ms ease,
    opacity 140ms ease;
}

.nostr-connect-button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow:
    0 10px 28px rgba(111, 69, 245, 0.34);
}

.nostr-connect-button:active:not(:disabled) {
  transform: translateY(0);
}

.nostr-connect-button:disabled {
  cursor: default;
  opacity: 0.78;
}

.nip46-test-lab-button {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 20;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 999px;
  padding: 7px 10px;
  background: rgba(17, 14, 29, 0.9);
  color: rgba(255, 255, 255, 0.86);
  font: inherit;
  font-size: 0.76rem;
  cursor: pointer;
  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.28);
}

.nip46-test-lab-button:hover {
  border-color: rgba(122, 92, 255, 0.72);
  color: #ffffff;
}

.nip46-test-lab-dialog {
  width: min(680px, calc(100vw - 28px));
  border: 1px solid rgba(122, 92, 255, 0.34);
  border-radius: 14px;
  padding: 0;
  background: #141120;
  color: #ffffff;
}

.nip46-test-lab-dialog::backdrop {
  background: rgba(0, 0, 0, 0.58);
}

.nip46-test-lab-content {
  padding: 20px;
}

.nip46-test-lab-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.nip46-test-lab-heading h2 {
  margin: 0;
  font-size: 1.15rem;
}

.nip46-test-lab-close {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  font: inherit;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}

.nip46-test-lab-description {
  margin: 12px 0 16px;
  color: rgba(255, 255, 255, 0.72);
  line-height: 1.45;
}

.nip46-test-lab-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.nip46-test-lab-actions button {
  border: 1px solid rgba(122, 92, 255, 0.42);
  border-radius: 10px;
  padding: 9px 12px;
  background: rgba(122, 92, 255, 0.16);
  color: #ffffff;
  font: inherit;
  cursor: pointer;
}

.nip46-test-lab-results {
  min-height: 48px;
}

.nip46-test-lab-uri-section {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.nip46-test-lab-uri-section h3 {
  margin: 0 0 12px;
  font-size: 1rem;
}

.nip46-test-lab-empty {
  margin: 0;
  color: rgba(255, 255, 255, 0.58);
}

.nip46-test-lab-result-list {
  display: grid;
  grid-template-columns: minmax(160px, 220px) minmax(0, 1fr);
  gap: 8px 14px;
  margin: 0;
}

.nip46-test-lab-result-list dt {
  color: rgba(255, 255, 255, 0.66);
  font-weight: 700;
}

.nip46-test-lab-result-list dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.nip46-test-lab-result-passed {
  color: #8ff0bd;
}

.nip46-test-lab-result-failed {
  color: #ff9aa8;
}

.nip46-test-lab-result-neutral {
  color: rgba(255, 255, 255, 0.86);
}

.nip46-test-lab-uri-output {
  display: grid;
  grid-template-columns: minmax(240px, 260px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  margin-top: 14px;
}

.nip46-test-lab-qr-panel {
  min-height: 260px;
}

.nip46-test-lab-qr {
  display: grid;
  place-items: center;
  width: 260px;
  min-height: 260px;
  border: 1px solid rgba(122, 92, 255, 0.34);
  border-radius: 10px;
  padding: 10px;
  background: #ffffff;
}

.nip46-test-lab-qr-placeholder {
  margin: 0;
  color: rgba(20, 17, 32, 0.74);
  font-size: 0.86rem;
  line-height: 1.35;
  text-align: center;
}

.nip46-test-lab-uri-controls {
  min-width: 0;
}

.nip46-test-lab-uri {
  display: block;
  width: 100%;
  min-height: 120px;
  border: 1px solid rgba(122, 92, 255, 0.34);
  border-radius: 10px;
  padding: 10px;
  resize: vertical;
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
  font: inherit;
  font-family:
    Consolas,
    "Liberation Mono",
    monospace;
  overflow-wrap: anywhere;
}

.nip46-test-lab-copy-uri {
  margin-top: 10px;
  border: 1px solid rgba(122, 92, 255, 0.42);
  border-radius: 10px;
  padding: 9px 12px;
  background: rgba(122, 92, 255, 0.16);
  color: #ffffff;
  font: inherit;
  cursor: pointer;
}

.nip46-test-lab-plaintext {
  display: block;
  width: 100%;
  min-height: 140px;
  margin-top: 14px;
  border: 1px solid rgba(143, 240, 189, 0.34);
  border-radius: 10px;
  padding: 10px;
  resize: vertical;
  background: rgba(143, 240, 189, 0.08);
  color: #ffffff;
  font: inherit;
  font-family:
    Consolas,
    "Liberation Mono",
    monospace;
  overflow-wrap: anywhere;
}

.nip46-test-lab-protocol-document {
  margin-top: 16px;
}

.nip46-test-lab-protocol-document h4 {
  margin: 0 0 10px;
  font-size: 0.94rem;
}

.nip46-test-lab-protocol-json {
  display: block;
  width: 100%;
  min-height: 170px;
  border: 1px solid rgba(122, 92, 255, 0.34);
  border-radius: 10px;
  padding: 10px;
  resize: vertical;
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
  font: inherit;
  font-family:
    Consolas,
    "Liberation Mono",
    monospace;
  overflow-wrap: anywhere;
}

.nip46-test-lab-ledger {
  margin-top: 16px;
  overflow-x: auto;
}

.nip46-test-lab-ledger h4 {
  margin: 0 0 10px;
  font-size: 0.94rem;
}

.nip46-test-lab-ledger table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}

.nip46-test-lab-ledger th,
.nip46-test-lab-ledger td {
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding: 6px 7px;
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

.nip46-test-lab-ledger th {
  color: rgba(255, 255, 255, 0.68);
  font-weight: 700;
}

@media (max-width: 720px) {
  .nip46-test-lab-uri-output {
    grid-template-columns: 1fr;
  }

  .nip46-test-lab-qr {
    width: min(260px, 100%);
    margin: 0 auto;
  }
}

@media (max-width: 520px) {
  .nip46-test-lab-result-list {
    grid-template-columns: 1fr;
  }
}

#chatMessages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 240px;
  max-height: 420px;
  overflow-y: auto;
  padding: 12px;
}

.new-chat-items-button {
  position: absolute;
  right: 20px;
  bottom: 82px;
  z-index: 3;

  padding: 8px 12px;
  border: 1px solid rgba(122, 92, 255, 0.45);
  border-radius: 999px;

  background: rgba(39, 35, 59, 0.96);
  color: #ffffff;

  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;

  box-shadow:
    0 8px 20px rgba(0, 0, 0, 0.28);
}

.new-chat-items-button:hover {
  border-color: rgba(122, 92, 255, 0.8);
}

.new-chat-items-button[hidden] {
  display: none;
}

.chat-message {
  padding: 10px 12px;
  border: 1px solid rgba(122, 92, 255, 0.2);
  border-radius: 12px;
  background: rgba(24, 21, 39, 0.72);
}

.chat-message-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 5px;
}

.chat-message-author {
  color: #bda9ff;
  font-size: 0.85rem;
  font-weight: 700;
}

.chat-message-time {
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.75rem;
}

.chat-message-content {
  margin: 0;
  color: rgba(255, 255, 255, 0.92);
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.zap-qr-code {
  display: flex;
  justify-content: flex-start;
  margin: 12px 0;
}

.zap-qr-code canvas {
  max-width: 240px;
  width: 100%;
  height: auto;
  background: white;
  padding: 8px;
  border-radius: 10px;
}

/* =====================================================
   Zap panel two-column layout
   ===================================================== */

.zap-panel {
  display: grid;
  grid-template-columns:
    minmax(0, 1fr)
    minmax(320px, 380px);
  grid-template-areas:
    "heading heading"
    "controls payment";
  gap: 18px 28px;
  align-items: start;
}

.zap-heading {
  grid-area: heading;
}

.zap-controls-column {
  grid-area: controls;
  min-width: 0;
}

.zap-payment {
  grid-area: payment;
  align-self: start;
  margin-top: -18px;

  position: static;
  width: auto;

  display: grid;
  grid-template-columns:
    180px
    minmax(0, 1fr);
  grid-template-areas:
    "qr summary"
    "qr actions";
  gap: 12px 16px;
  align-items: center;

  padding: 16px;

  border: 1px solid
    rgba(122, 92, 255, 0.32);

  border-radius: 14px;

  background:
    rgba(17, 14, 29, 0.78);
}

.zap-payment[hidden] {
  display: none;
}

#zapPaymentSummary {
  grid-area: summary;
  margin: 0;
}

.zap-qr-code {
  grid-area: qr;
  width: 180px;
  height: 180px;
}

.zap-qr-code img,
.zap-qr-code canvas {
  display: block;
  width: 180px !important;
  height: 180px !important;
}

.zap-payment-actions {
  grid-area: actions;

  display: grid;
  gap: 8px;
}

.zap-payment-actions button {
  width: 100%;
}

.zap-amount-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: nowrap;
}

.zap-amount-button {
    flex: 1;
    min-width: 0;
}

.custom-zap-controls {
  display: grid;
  grid-template-columns:
    minmax(180px, 280px)
    minmax(220px, 1fr);
  gap: 12px;
}

#customZapButton {
  width: 100%;
}

@media (max-width: 900px) {
  .zap-panel {
    grid-template-columns: 1fr;
    grid-template-areas:
      "heading"
      "payment"
      "controls";
  }

  .zap-payment {
    grid-template-columns:
      150px
      minmax(0, 1fr);
  }

  .zap-qr-code,
  .zap-qr-code img,
  .zap-qr-code canvas {
    width: 150px !important;
    height: 150px !important;
  }
}

/* =====================================================
   Compact streamer / connected-user bar
   ===================================================== */

.streamer-card {
  padding: 10px 16px;
  margin-bottom: 14px;
}

.streamer-avatar-shell {
  width: 50px;
  height: 50px;
}

.viewer-identity {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.viewer-avatar {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
}

.viewer-identity-copy {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

#nostrConnectionStatus {
  white-space: nowrap;
  color: var(--text-soft);
  font-size: 0.88rem;
}

.nostr-connect-button {
  padding: 9px 15px;
  border-radius: 10px;
}

.configure-stream-button {
  margin-top: 0;
  padding: 9px 14px;
}

@media (max-width: 760px) {
  .streamer-card {
    grid-template-columns:
      auto
      minmax(0, 1fr);
  }

  .viewer-identity {
    grid-column: 1 / -1;
    width: 100%;
    margin-left: 0;
  }

  .viewer-identity-copy {
    flex: 1;
    flex-wrap: wrap;
    order: 1;
  }

  .nostr-connect-button,
  .configure-stream-button {
    flex: 1;
  }

  .viewer-avatar {
    order: 0;
  }

  #configureStreamButton {
    order: 2;
  }

  #announceStreamButton {
    order: 3;
  }

  #endStreamButton {
    order: 4;
  }
}

/* =====================================================
   Final compact desktop layout pass
   ===================================================== */

/* Pull the whole page closer to the top */
.stream-app {
  padding-top: 10px;
}

/* Compact the page title area */
.stream-header {
  margin-bottom: 10px;
  gap: 16px;
}

.stream-brand-label {
  margin-bottom: 3px;
}

.stream-header h1 {
  margin-bottom: 4px;
  font-size: clamp(1.8rem, 3.4vw, 2.8rem);
}

.stream-description {
  font-size: 0.92rem;
  line-height: 1.25;
}

/* Keep the identity bar short */
.streamer-card {
  margin-bottom: 12px;
  padding-top: 8px;
  padding-bottom: 8px;
}

/* The full npub is not useful in the main viewing layout */
.streamer-npub {
  display: none;
}

/* Reduce the identity text height after hiding the npub */
.streamer-details .section-label {
  margin-bottom: 3px;
}

/* Compact video and chat headings */
.video-panel .section-label,
.chat-panel .section-label {
  display: none;
}

.video-panel .panel-heading,
.chat-panel .panel-heading {
  min-height: 28px;
}

.video-panel .panel-heading h2,
.chat-panel .panel-heading h2 {
  font-size: 1.12rem;
}

/* Bring the embedded video and chat history closer to their headings */
.rumble-player-shell,
.chat-messages {
  margin-top: 8px;
}

/* Slightly tighter panel padding */
.video-panel,
.chat-panel {
  padding: 13px;
}

/* Slightly smaller gap between video and chat */
.stream-workspace {
  gap: 14px;
}

/* =====================================================
   Help Dialog
   ===================================================== */

.help-dialog {
  width: min(92vw, 640px);
  max-height: min(86vh, 760px);

  padding: 0;

  color: #f7f5ff;
  background:
    linear-gradient(
      145deg,
      rgba(35, 30, 57, 0.98),
      rgba(20, 18, 34, 0.99)
    );

  border:
    1px solid
    rgba(139, 111, 255, 0.5);

  border-radius: 18px;

  box-shadow:
    0 24px 70px
    rgba(0, 0, 0, 0.6),
    0 0 35px
    rgba(111, 78, 255, 0.18);

  overflow: hidden;
}

.help-dialog::backdrop {
  background:
    rgba(7, 6, 14, 0.76);

  backdrop-filter:
    blur(5px);
}

.help-dialog-content {
  display: flex;
  flex-direction: column;

  max-height: inherit;
}

.help-dialog-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;

  padding: 20px 22px 18px;

  background:
    rgba(91, 65, 170, 0.18);

  border-bottom:
    1px solid
    rgba(139, 111, 255, 0.28);
}

.help-dialog-heading h2 {
  margin: 0;

  color: #ffffff;

  font-size:
    clamp(1.25rem, 3vw, 1.65rem);

  line-height: 1.2;
}

.help-dialog-close {
  flex: 0 0 auto;

  width: 38px;
  height: 38px;

  display: grid;
  place-items: center;

  padding: 0;

  color: #ddd7ff;
  background:
    rgba(255, 255, 255, 0.08);

  border:
    1px solid
    rgba(255, 255, 255, 0.14);

  border-radius: 10px;

  font-size: 1.35rem;
  line-height: 1;

  cursor: pointer;

  transition:
    background 150ms ease,
    border-color 150ms ease,
    transform 150ms ease;
}

.help-dialog-close:hover {
  background:
    rgba(139, 111, 255, 0.24);

  border-color:
    rgba(169, 148, 255, 0.55);

  transform:
    translateY(-1px);
}

.help-dialog-close:focus-visible {
  outline:
    3px solid
    rgba(171, 151, 255, 0.55);

  outline-offset: 2px;
}

#helpDialogBody {
  padding: 22px;

  overflow-y: auto;

  scrollbar-width: thin;
}

.help-dialog-intro {
  margin:
    0 0 22px;

  padding: 14px 16px;

  color: #eeeaff;
  background:
    rgba(111, 78, 255, 0.12);

  border-left:
    3px solid
    rgba(151, 126, 255, 0.9);

  border-radius: 0 10px 10px 0;

  line-height: 1.55;
}

.help-dialog-section {
  margin-top: 24px;
}

.help-dialog-section:first-of-type {
  margin-top: 0;
}

.help-dialog-section h3 {
  margin:
    0 0 10px;

  color: #ffffff;

  font-size: 1.05rem;
  line-height: 1.3;
}

.help-dialog-section p {
  margin:
    0 0 12px;

  color: #cec8df;

  line-height: 1.6;
}

.help-dialog-section p:last-child {
  margin-bottom: 0;
}

.help-dialog-section ol {
  margin:
    12px 0 0;

  padding-left: 1.6rem;

  color: #ddd8eb;
}

.help-dialog-section li {
  margin-bottom: 8px;

  padding-left: 4px;

  line-height: 1.45;
}

.help-dialog-section li::marker {
  color: #a98cff;
  font-weight: 700;
}

.help-dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;

  padding: 16px 22px 20px;

  border-top:
    1px solid
    rgba(139, 111, 255, 0.22);

  background:
    rgba(14, 12, 25, 0.55);
}

.help-dialog-actions[hidden] {
  display: none;
}

.help-dialog-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  min-height: 42px;

  padding: 10px 16px;

  color: #ffffff;
  background:
    linear-gradient(
      135deg,
      #7357d9,
      #5839b7
    );

  border:
    1px solid
    rgba(178, 158, 255, 0.38);

  border-radius: 10px;

  text-decoration: none;
  font-weight: 700;

  box-shadow:
    0 8px 20px
    rgba(49, 29, 112, 0.3);

  transition:
    transform 150ms ease,
    filter 150ms ease;
}

.help-dialog-action:hover {
  filter: brightness(1.1);

  transform:
    translateY(-1px);
}

.help-dialog-action:focus-visible {
  outline:
    3px solid
    rgba(171, 151, 255, 0.55);

  outline-offset: 2px;
}

@media (max-width: 560px) {
  .help-dialog {
    width: calc(100vw - 24px);
    max-height: calc(100dvh - 24px);

    border-radius: 14px;
  }

  .help-dialog-heading {
    padding: 17px 16px;
  }

  #helpDialogBody {
    padding: 18px 16px;
  }

  .help-dialog-actions {
    flex-direction: column;

    padding: 14px 16px 18px;
  }

  .help-dialog-action {
    width: 100%;
  }
}
#announceStreamDialog {
  width: min(520px, calc(100vw - 32px));
  padding: 24px;
}

#announcementText {
  width: 100%;
  min-height: 260px;
  box-sizing: border-box;
  resize: vertical;
}
