/* GLOBAL & RESET */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  touch-action: pan-x pan-y;
}

/* ── СВЕТЛАЯ ТЕМА (по умолчанию) ─────────────────────────────── */
:root {
  --bg-color: #eef0f5;
  --header-bg: rgba(232, 236, 246, 0.94);
  --card-bg: rgba(255, 255, 255, 0.88);
  --modal-bg: #f3f5fb;
  --modal-overlay-bg: rgba(0, 0, 0, 0.45);
  --gesture-card-bg: rgba(255, 255, 255, 0.92);
  --dropdown-bg: #f3f5fb;
  --scroll-btn-bg: rgba(210, 215, 232, 0.92);

  --login-gradient: radial-gradient(circle at center, #dde2f3 0%, #cacfe8 100%);

  --surface-1: rgba(0, 0, 0, 0.04);
  --surface-2: rgba(0, 0, 0, 0.06);
  --surface-hover: rgba(0, 0, 0, 0.07);
  --surface-active: rgba(0, 0, 0, 0.12);
  --input-bg: rgba(0, 0, 0, 0.06);
  --badge-bg: rgba(0, 0, 0, 0.06);

  --border-color: rgba(0, 0, 0, 0.09);
  --text-primary: #1e2035;
  --text-secondary: #64748b;
  --text-on-input: #1e2035;

  --accent-blue: #3b82f6;
  --accent-blue-glow: rgba(59, 130, 246, 0.3);
  --accent-red: #ef4444;
  --accent-red-glow: rgba(239, 68, 68, 0.3);
  --accent-purple: #8b5cf6;
  --accent-purple-glow: rgba(139, 92, 246, 0.3);
  --success-color: #10b981;
}

/* ── ТЁМНАЯ ТЕМА (автоматически по системе) ──────────────────── */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-color: #0f1019;
    --header-bg: rgba(13, 15, 25, 0.94);
    --card-bg: rgba(22, 24, 36, 0.8);
    --modal-bg: #13151f;
    --modal-overlay-bg: rgba(0, 0, 0, 0.75);
    --gesture-card-bg: rgba(24, 27, 42, 0.78);
    --dropdown-bg: #151722;
    --scroll-btn-bg: rgba(22, 24, 36, 0.92);

    --login-gradient: radial-gradient(circle at center, #1b2035 0%, #0c0d12 100%);

    --surface-1: rgba(255, 255, 255, 0.04);
    --surface-2: rgba(255, 255, 255, 0.05);
    --surface-hover: rgba(255, 255, 255, 0.08);
    --surface-active: rgba(255, 255, 255, 0.15);
    --input-bg: rgba(0, 0, 0, 0.35);
    --badge-bg: rgba(255, 255, 255, 0.05);

    --border-color: rgba(255, 255, 255, 0.08);
    --text-primary: #e8eaf0;
    --text-secondary: #8c92a4;
    --text-on-input: #e8eaf0;
  }
}

/* ── BASE BODY ────────────────────────────────────────────────── */
/* html paints the theme bg on the root canvas so no uncovered region
   (e.g. the iOS home-indicator safe-area) ever shows white. */
html {
  background-color: var(--bg-color);
}

body {
  position: relative;
  background-color: var(--bg-color);
  color: var(--text-primary);
  /* DOCUMENT SCROLL (not an app-shell): no overflow:hidden, no fixed height. The panel scrolls at
     the document level so iOS Safari auto-hides its bottom toolbar on scroll-down (verified on the
     iPhone 17 Pro Max simulator). An inner-overflow app-shell keeps Safari's bar permanently shown. */
  min-height: 100svh;
  min-height: 100dvh;
  width: 100vw;
}

/* SCREEN MANAGEMENT */
.screen {
  display: none;
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
}

.screen.active {
  display: flex;
  flex-direction: column;
}

/* PANEL = document scroll (overrides the absolute app-shell used by the login screen) so iOS
   Safari auto-hides its bottom toolbar on scroll-down. Header sticks; feed flows in the document. */
#panel-screen.active {
  position: static;
  height: auto;
  min-height: 100dvh;
  display: block;
}
#panel-screen .header {
  position: sticky;
  top: 0;
}
#panel-screen .chat-container {
  flex: none;
  overflow: visible;
}

/* GLASS EFFECT CARD */
.glass-card {
  background: var(--card-bg);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.15);
  border-radius: 20px;
}

/* LOGIN SCREEN */
#login-screen {
  align-items: center;
  justify-content: center;
  background: var(--login-gradient);
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  padding: 30px 24px;
  text-align: center;
}

.logo-area {
  margin-bottom: 25px;
  position: relative;
}

.logo-pulse {
  width: 60px;
  height: 60px;
  background: var(--accent-blue);
  border-radius: 50%;
  margin: 0 auto 15px;
  box-shadow: 0 0 20px var(--accent-blue-glow);
  position: relative;
}

.logo-pulse::after {
  content: '';
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  border: 2px solid var(--accent-blue);
  opacity: 0.5;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.9); opacity: 0.8; }
  100% { transform: scale(1.3); opacity: 0; }
}

.login-card h1 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 6px;
  letter-spacing: -0.5px;
  color: var(--text-primary);
}

.subtitle {
  font-size: 13px;
  color: var(--text-secondary);
}

.input-group {
  margin-bottom: 16px;
  position: relative;
}

.input-group input {
  width: 100%;
  padding: 14px 16px;
  background: var(--input-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  color: var(--text-on-input);
  font-size: 16px;
  outline: none;
  text-align: center;
  transition: all 0.3s ease;
}

.input-group input:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 10px var(--accent-blue-glow);
}

#login-pin {
  font-size: 24px;
  letter-spacing: 6px;
  font-weight: bold;
}

/* CUSTOM NUMERIC KEYPAD */
.numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 20px 0;
}

.num-btn {
  padding: 16px 0;
  background: var(--surface-2);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  color: var(--text-primary);
  font-size: 20px;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  transition: background 0.2s, transform 0.1s;
}

.num-btn:active {
  background: var(--surface-active);
  transform: scale(0.95);
}

.clear-btn {
  color: var(--accent-red);
}

.back-btn {
  color: var(--text-secondary);
  font-size: 16px;
}

.error-text {
  color: var(--accent-red);
  font-size: 13px;
  margin: 10px 0;
  min-height: 18px;
}

.error-text.hidden {
  display: none;
}

.primary-btn {
  width: 100%;
  padding: 14px;
  background: var(--accent-blue);
  border: none;
  border-radius: 12px;
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.3s, box-shadow 0.3s;
}

.primary-btn:hover {
  background: #2563eb;
  box-shadow: 0 0 15px var(--accent-blue-glow);
}

.primary-btn:active {
  transform: scale(0.99);
}

.secondary-btn {
  padding: 12px 20px;
  background: var(--surface-hover);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.secondary-btn:hover {
  background: var(--surface-active);
}

.danger-btn {
  background: var(--accent-red);
}
.danger-btn:hover {
  background: #dc2626;
  box-shadow: 0 0 15px var(--accent-red-glow);
}

/* MAIN PANEL HEADER */
.header {
  padding: calc(16px + env(safe-area-inset-top, 0px)) 16px 12px;
  background: var(--header-bg);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
  backdrop-filter: blur(12px);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.live-dot {
  width: 6px;
  height: 6px;
  background: var(--success-color);
  border-radius: 50%;
  box-shadow: 0 0 6px var(--success-color);
  animation: blink 2s infinite;
}

@keyframes blink {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

.header-left h2 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.3px;
  color: var(--text-primary);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

/* keep the icon buttons + burger from being clipped — only the name shrinks */
.header-right > .hdr-btn,
.header-right > .burger-menu {
  flex-shrink: 0;
}

.username {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
  background: var(--badge-bg);
  padding: 3px 8px;
  border-radius: 16px;
  border: 1px solid var(--border-color);
  max-width: 84px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-btn {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
  border-radius: 8px;
  color: var(--text-primary);
}

.icon-btn:hover {
  background: var(--surface-hover);
}

/* HEADER ACTION BUTTONS — перезагрузка браузера + пользователи, в шапке */
.hdr-btn {
  position: relative;
  background: var(--surface-1);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  font-size: 17px;
  line-height: 1;
  padding: 7px 9px;
  cursor: pointer;
  color: var(--text-primary);
  transition: background 0.2s, transform 0.15s;
}

.hdr-btn:hover {
  background: var(--surface-hover);
}

.hdr-btn:active {
  transform: scale(0.94);
}

/* BUSY / LOADING STATE FOR ACTION BUTTONS (screenshot, restarts, reboot) */
@keyframes btn-spin {
  to { transform: rotate(360deg); }
}

.btn-busy {
  position: relative;
  pointer-events: none;
  opacity: 0.75;
}

.btn-busy > * {
  visibility: hidden;
}

.btn-busy::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border: 2.5px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  opacity: 0.9;
  animation: btn-spin 0.7s linear infinite;
}

/* FLOATING ISLAND SCREENSHOT BUTTON — левитирует, без подложки */
.fab-screenshot {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 22px;
  background: var(--accent-blue);
  color: #fff;
  border: none;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  z-index: 200;
  /* neutral drop shadow = levitation, NOT a coloured halo that reads as a backdrop panel */
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
  transition: transform 0.15s, box-shadow 0.2s;
}

.fab-screenshot .btn-icon {
  font-size: 16px;
}

.fab-screenshot:hover {
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
}

.fab-screenshot:active {
  transform: translateX(-50%) scale(0.96);
}

/* CHAT FEED */
.chat-container {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  /* Bottom clearance so the last message scrolls clear of BOTH the floating Safari bar
     (overlays content, env=0 in a tab → fixed px) and the FAB. scroll-padding-bottom makes
     programmatic/anchored scrolls stop clear too. Tune via the 🧪 test pages. */
  padding: 16px 16px calc(env(safe-area-inset-bottom, 0px) + 120px) 16px;
  scroll-padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 120px);
  background: var(--bg-color);
  display: flex;
  flex-direction: column;
}

.chat-feed {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
}

/* CHAT SYSTEM & ACTION PILLS */
.system-msg-pill {
  align-self: center;
  padding: 6px 14px;
  border-radius: 20px;
  background: var(--surface-2);
  border: 1px solid var(--border-color);
  font-size: 11px;
  color: var(--text-secondary);
  text-align: center;
  max-width: 90%;
  letter-spacing: 0.2px;
}

.system-msg-pill.system-reboot {
  background: rgba(59, 130, 246, 0.12);
  border-color: rgba(59, 130, 246, 0.2);
  color: #3b82f6;
}

.system-msg-pill.action-reboot {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.2);
  color: var(--accent-red);
}

.system-msg-pill.action-users {
  background: rgba(139, 92, 246, 0.12);
  border-color: rgba(139, 92, 246, 0.2);
  color: var(--accent-purple);
}

.system-msg-pill.action-app-launch {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.2);
  color: var(--success-color);
}

/* CHAT LOG MESSAGE BUBBLES */
.gesture-message {
  align-self: flex-start;
  width: 220px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.gesture-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-secondary);
  padding-left: 6px;
}

.gesture-card {
  padding: 6px;
  background: var(--gesture-card-bg);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.screenshot-wrapper {
  position: relative;
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
  cursor: pointer;
  margin: 0 auto;
}

.screenshot-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 1;
  transition: opacity 0.3s;
}

/* GESTURE DOTS / ARROWS */
.svg-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.pulse-dot {
  position: absolute;
  width: 8px;
  height: 8px;
  background: var(--accent-red);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 6px var(--accent-red);
}

.pulse-dot::after {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 1px solid var(--accent-red);
  animation: dot-pulse 1.5s infinite;
  box-sizing: border-box;
  left: 0;
  top: 0;
}

@keyframes dot-pulse {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(3.5); opacity: 0; }
}

/* MODAL WINDOWS */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--modal-overlay-bg);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 1;
  transition: opacity 0.25s ease;
  padding: 16px;
}

.modal-overlay.hidden {
  display: none;
  opacity: 0;
  pointer-events: none;
}

.modal-card {
  width: 100%;
  max-width: 400px;
  background: var(--modal-bg);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  animation: modal-zoom 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modal-zoom {
  0% { transform: scale(0.9); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
}

.modal-close:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 20px;
}

.modal-divider {
  border: 0;
  height: 1px;
  background: var(--border-color);
  margin: 18px 0;
}

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-form h4 {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.modal-input-group input {
  width: 100%;
  padding: 12px 14px;
  background: var(--input-bg);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  color: var(--text-on-input);
  font-size: 16px;
  outline: none;
}

.modal-input-group input:focus {
  border-color: var(--accent-purple);
  box-shadow: 0 0 8px var(--accent-purple-glow);
}

/* Admin checkbox row in Add User form — opt out of the full-width text-input styling */
.modal-checkbox-group label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 14px;
}

.modal-checkbox-group input[type="checkbox"] {
  width: auto;
  margin: 0;
  padding: 0;
  flex: none;
  accent-color: var(--accent-purple);
}

/* USERS LIST IN MODAL */
.users-list-container h4 {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

#users-list {
  list-style: none;
  max-height: 180px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#users-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--surface-1);
  border: 1px solid var(--border-color);
  border-radius: 8px;
}

#users-list li span {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.delete-user-btn {
  background: none;
  border: none;
  color: var(--accent-red);
  cursor: pointer;
  padding: 4px 8px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 4px;
}

.delete-user-btn:hover {
  background: rgba(239, 68, 68, 0.1);
}

/* CONFIRM CARD */
.confirm-card {
  max-width: 320px;
  text-align: center;
}

.confirm-card .modal-body {
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.warning-icon {
  font-size: 40px;
  margin-bottom: 4px;
}

.confirm-card h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.confirm-card p {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-bottom: 12px;
}

.confirm-actions {
  display: flex;
  gap: 10px;
  width: 100%;
}

.confirm-actions button {
  flex: 1;
}

/* SCREENSHOT VIEWER MODAL */
.viewer-overlay {
  background: rgba(0, 0, 0, 0.95);
  display: flex;
  flex-direction: column;
}

.viewer-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  z-index: 110;
  display: flex;
  align-items: center;
  justify-content: center;
}

.viewer-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.viewer-container {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.viewer-image-wrapper {
  position: relative;
  max-width: 100%;
  max-height: 80vh;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
  border-radius: 8px;
  overflow: hidden;
  aspect-ratio: 9 / 16;
}

.viewer-image-wrapper img {
  max-width: 100%;
  max-height: 80vh;
  width: auto;
  height: auto;
  display: block;
}

.viewer-footer {
  width: 100%;
  max-width: 600px;
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 110;
}

.viewer-info {
  font-size: 12px;
  color: var(--text-secondary);
}

.hd-toggle-btn {
  padding: 6px 14px;
  background: var(--surface-hover);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  color: var(--text-primary);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.hd-toggle-btn.active {
  background: var(--accent-blue);
  border-color: var(--accent-blue);
  box-shadow: 0 0 8px var(--accent-blue-glow);
  color: #fff;
}

/* RESPONSIVE DESIGN */
@media (min-width: 768px) {
  .gesture-message {
    max-width: 65%;
  }
}

/* BURGER MENU */
.burger-menu {
  position: relative;
  display: inline-block;
}

#burger-btn {
  font-size: 20px;
  color: var(--text-primary);
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 8px;
  transition: background 0.2s;
}

#burger-btn:hover {
  background: var(--surface-hover);
}

.burger-dropdown {
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 8px;
  width: 180px;
  background: var(--dropdown-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  padding: 6px 0;
}

.burger-dropdown.hidden {
  display: none;
}

.burger-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 16px;
  background: none;
  border: none;
  color: var(--text-primary);
  text-decoration: none;
  text-align: left;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s;
}

.burger-item:hover {
  background: var(--surface-1);
}

.burger-item.accent-red {
  color: var(--accent-red);
}

.burger-item.accent-red:hover {
  background: rgba(239, 68, 68, 0.1);
}

.burger-divider {
  border: 0;
  height: 1px;
  background: var(--border-color);
  margin: 4px 0;
}

/* SCROLL TO BOTTOM BUTTON */
.scroll-bottom-btn {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  right: 24px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--scroll-btn-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 100;
  transition: opacity 0.3s, transform 0.3s;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.scroll-bottom-btn.hidden {
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
}

.scroll-bottom-btn:hover {
  background: var(--surface-hover);
  transform: translateY(-2px);
}

/* Manual-screenshot pending placeholder — spinner shown until the capture lands */
.screenshot-wrapper.pending-shot {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(255, 255, 255, 0.04);
  cursor: default;
}
.shot-spinner {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--accent-blue);
  animation: shot-spin 0.9s linear infinite;
}
@keyframes shot-spin { to { transform: rotate(360deg); } }
.shot-pending-label {
  color: #9aa0aa;
  font-size: 14px;
  letter-spacing: 0.2px;
}

.diagnostics { margin: 88px auto 16px; padding: 16px; width: min(94%, 1100px); box-sizing: border-box; }
.diagnostics summary { cursor: pointer; font-weight: 600; }
.diagnostics select { max-width: 100%; margin: 8px; padding: 8px; }
.diagnostic-content { display: flex; gap: 16px; align-items: flex-start; margin-top: 16px; }
#diagnostic-image { width: 180px; max-width: 35%; cursor: zoom-in; }
#diagnostic-logs { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 500px; overflow: auto; flex: 1; font-size: 12px; }

/* One document-scrolling feed. The live message is its permanent last row. */
[hidden] { display: none !important; }
.header-right { flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.hdr-btn { width: auto; min-height: 40px; padding: 8px 12px; font-size: 13px; gap: 6px; }
.section-heading { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: baseline; margin: 0 0 14px; }
.section-heading h3 { font-size: 17px; }
.section-heading span { font-size: 12px; color: var(--text-secondary); }
#panel-screen .chat-container { max-width: 648px; margin: 0 auto; padding: 24px 24px 110px; }
.chat-feed { gap: 18px; }
.chat-feed .system-msg-pill { align-self: flex-start; text-align: left; }
.chat-live-message { align-self: flex-end; width: 220px; max-width: 100%; margin-top: 18px; }

.live-card { width: 220px; max-width: 100%; padding: 6px; }
.live-header { display: flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 4px; margin-bottom: 4px; }
.live-header h3 { font-size: 14px; }
.live-status { margin-left: auto; font-size: 12px; white-space: nowrap; }
#btn-live-retry { padding: 3px 7px; line-height: 1; }
.live-screen { position: relative; width: 100%; height: auto; aspect-ratio: 9 / 16; min-height: 0; display: flex; align-items: center; justify-content: center; background: #07090d; border-radius: 12px; overflow: hidden; }
.live-screen img { width: 100%; height: 100%; object-fit: contain; }
.screen-curtain { display: none; position: absolute; inset: 0; background: #000; }
.screen-hidden .screen-curtain { display: block; }
.live-note { font-size: 12px; color: var(--text-secondary); line-height: 1.5; margin-top: 9px; }
/* The feedback and jump button share a row above the fixed controls. */
.control-dock { position: fixed; z-index: 200; left: 50%; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); width: min(360px, calc(100vw - 24px)); }
.control-toolbar { display: flex; gap: 6px; padding: 6px; border-radius: 16px; background: var(--modal-bg); }
.control-toolbar > button { flex: 1; min-width: 0; min-height: 44px; padding: 8px 4px; font-size: 13px; white-space: nowrap; }
.control-feedback { display: flex; align-items: flex-end; gap: 8px; }
.control-feedback .scroll-bottom-btn { position: static; flex: none; margin: 0 0 8px auto; }
.control-feedback .scroll-bottom-btn.hidden, #control-result:empty { display: none; }
#control-result { flex: 1; margin: 0 0 8px; padding: 6px 10px; border-radius: 10px; background: var(--modal-bg); font-size: 12px; line-height: 1.5; max-height: 80px; overflow-y: auto; overflow-wrap: anywhere; }
#panel-screen:has(#control-result:not(:empty)) .chat-container { padding-bottom: calc(165px + env(safe-area-inset-bottom, 0px)); }
.kiosk-controls-menu { position: absolute; bottom: calc(100% + 8px); left: 0; width: 100%; max-height: calc(100dvh - 165px - env(safe-area-inset-bottom, 0px)); overflow-y: auto; padding: 14px; background: var(--modal-bg); }
.controls-menu-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.controls-menu-header h3 { font-size: 16px; }
.controls-menu-actions { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; margin-top: 12px; }
.controls-menu-actions button { padding: 12px; font-size: 13px; }
button:disabled { opacity: .5; cursor: not-allowed; }
button:focus-visible,a:focus-visible { outline: 3px solid var(--accent-blue); outline-offset: 3px; }
.event-metadata { white-space: normal; text-align: left; }
.diagnostics { align-self: flex-start; margin: 10px 0 0; width: fit-content; max-width: 100%; padding: 7px 12px; border-radius: 14px; font-size: 13px; }
.diagnostics[open] { width: min(100%, 360px); }
.diagnostics[open] > summary { margin-bottom: 9px; }
.diagnostic-problem { margin-left: 5px; padding: 2px 6px; border-radius: 6px; background: #ffe3a6; color: #572d00; font-size: 11px; }
.diagnostics>p { margin-bottom: 10px; line-height: 1.5; }
.diagnostic-content { flex-wrap: wrap; }
#help-modal { z-index: 1001; }
#confirm-modal { z-index: 1002; }
.help-card { width: min(620px,100%); max-height: min(90dvh,900px); overflow: auto; }
.help-body { line-height: 1.6; }
.help-body section { padding: 16px 0; border-bottom: 1px solid var(--border-color); }
.help-body h4 { font-size: 15px; margin-bottom: 5px; }
.help-body p { font-size: 13px; margin: 8px 0; color: var(--text-secondary); }
.help-body button { margin-top: 10px; margin-right: 6px; padding: 10px 14px; }
.help-body #help-done { width: 100%; }
.modal-close-help { color: var(--text-primary); background: var(--surface-hover); border: 0; border-radius: 8px; width: 40px; height: 40px; flex-shrink: 0; cursor: pointer; }
.help-contact { color: var(--accent-blue); text-underline-offset: 3px; }
#help-connection { padding: 12px; border-radius: 10px; background: var(--surface-2); }
@media(max-width:767px) {
  .header { padding: 10px 12px; gap: 8px; }
  .header-left h2 { font-size: 17px; }
  .header-right { gap: 4px; }
  .hdr-btn { padding: 7px 8px; font-size: 12px; }
  .username { display: none; }
  #panel-screen .chat-container { padding: 16px 12px 100px; }
  .section-heading { margin-bottom: 10px; }
  .modal-overlay { padding: 12px; }
  .help-card { max-height: calc(100dvh - 24px); border-radius: 16px; }
  .help-body { padding: 16px; }
  .help-body button { width: 100%; }
}

.capture-warning { padding: 10px; border: 1px solid #b88629; border-radius: 10px; line-height: 1.5; background: rgba(184,134,41,.1); }

/* Kiosk state next to the title; the dot and label share one colour. */
.kiosk-state{font-size:12px;font-weight:600;color:var(--success-color)}
.kiosk-state[data-state="warn"]{color:#b88629}
.kiosk-state[data-state="offline"]{color:#c0392b}
.kiosk-state[data-state="unknown"]{color:inherit;opacity:.6}
.live-dot[data-state="warn"]{background:#b88629;box-shadow:0 0 6px #b88629}
.live-dot[data-state="offline"]{background:#c0392b;box-shadow:0 0 6px #c0392b;animation:none}
.live-dot[data-state="unknown"]{background:#888;box-shadow:none;animation:none}
.kiosk-state{white-space:nowrap}
@media (max-width:480px){
  .kiosk-state{font-size:11px}
  .header-right .hdr-btn{padding:6px 8px;font-size:12px}
  .header-right{gap:6px}
}

.feed-more{align-self:center;margin:8px auto;font-size:12px;padding:6px 14px}

/* Enlarged broadcast: the same card, fixed over the page, picture scaled to the screen. */
.live-screen{cursor:zoom-in}
body.live-open{overflow:hidden}
.chat-live-message.live-expanded{position:fixed;top:0;left:0;right:0;bottom:0;width:auto;max-width:none;height:auto;margin:0;z-index:1000;display:flex;flex-direction:column;align-items:center;gap:8px;padding:max(10px,env(safe-area-inset-top)) 12px max(10px,env(safe-area-inset-bottom));background:#08090e}
.chat-live-message.live-expanded .live-header{width:min(100%,640px);color:#fff}
.chat-live-message.live-expanded .live-card{flex:none;width:auto;max-width:100%;display:block;padding:4px}
.chat-live-message.live-expanded .live-screen{height:calc(100dvh - 96px);width:auto;max-width:calc(100vw - 32px);aspect-ratio:9/16;cursor:zoom-out}
.chat-live-message.live-expanded .live-screen img{width:100%;height:100%;object-fit:contain}
#btn-live-expand{min-width:34px}
.chat-live-message.live-expanded .secondary-btn{color:#fff;background:rgba(255,255,255,.16);border:1px solid rgba(255,255,255,.4)}
.chat-live-message.live-expanded .live-status{color:#fff}
