:root {
  --bg-console: #0f141c;
  --bg-panel: #171e29;
  --bg-card: #1e2736;
  --border-subtle: #2b374b;
  --border-focus: #38bdf8;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --optical-white: #ffffff;
  --signal-amber: #f59e0b;
  --telemetry-cyan: #0ea5e9;
  --verified-emerald: #10b981;
  --danger-rose: #f43f5e;

  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Code", "Consolas", monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  background-color: var(--bg-console);
  color: var(--text-primary);
  font-family: var(--font-sans);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-text-size-adjust: 100%;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.hidden {
  display: none !important;
}

/* ==================== Top Header ==================== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.25rem;
  background-color: var(--bg-panel);
  border-bottom: 1px solid var(--border-subtle);
  gap: 0.85rem;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.brand-badge {
  background: linear-gradient(135deg, var(--telemetry-cyan), #2563eb);
  color: #fff;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.82rem;
  padding: 0.32rem 0.6rem;
  border-radius: 6px;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}

.brand-title {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-subtitle {
  font-size: 0.76rem;
  color: var(--text-secondary);
}

.view-switcher {
  display: flex;
  background: var(--bg-console);
  padding: 0.22rem;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  gap: 0.22rem;
}

.tab-btn {
  background: transparent;
  color: var(--text-secondary);
  border: none;
  padding: 0.42rem 0.85rem;
  border-radius: 6px;
  font-size: 0.83rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  text-align: center;
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  background: var(--bg-card);
  color: var(--text-primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* ==================== Workspace Layout ==================== */
.workspace {
  flex: 1;
  padding: 1.1rem;
  display: grid;
  gap: 1.1rem;
  max-width: 1720px;
  width: 100%;
  margin: 0 auto;
}

.workspace.mode-split {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.workspace.mode-sender,
.workspace.mode-receiver {
  grid-template-columns: minmax(0, 1040px);
  justify-content: center;
}

.workspace.mode-sender .receiver-panel {
  display: none;
}

.workspace.mode-receiver .sender-panel {
  display: none;
}

@media (max-width: 1200px) {
  .workspace.mode-split {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ==================== Panel Common ==================== */
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.95rem;
  min-width: 0;
  max-width: 100%;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.panel-title-group {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
}

.panel-title-group h2 {
  font-size: 1.02rem;
  font-weight: 600;
}

.direction-tag {
  font-family: var(--font-mono);
  font-size: 0.73rem;
  font-weight: 700;
  padding: 0.18rem 0.5rem;
  border-radius: 4px;
  flex-shrink: 0;
}

.tag-tx {
  background: rgba(245, 158, 11, 0.16);
  color: var(--signal-amber);
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.tag-rx {
  background: rgba(16, 185, 129, 0.16);
  color: var(--verified-emerald);
  border: 1px solid rgba(16, 185, 129, 0.35);
}

/* ==================== Source Card, Dropzone & Text Input ==================== */
.source-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-width: 0;
}

.source-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  background: var(--bg-console);
  padding: 3px;
  border-radius: 7px;
  border: 1px solid var(--border-subtle);
  gap: 4px;
}

.source-tab-btn {
  background: transparent;
  color: var(--text-secondary);
  border: none;
  padding: 0.42rem 0.5rem;
  border-radius: 5px;
  font-size: 0.81rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: center;
  white-space: nowrap;
}

.source-tab-btn:hover {
  color: var(--text-primary);
}

.source-tab-btn.active {
  background: var(--bg-card);
  color: var(--signal-amber);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

.file-dropzone {
  background: var(--bg-console);
  border: 1.5px dashed var(--border-subtle);
  border-radius: 8px;
  padding: 0.85rem 0.95rem;
  transition: border-color 0.2s, background-color 0.2s;
}

.file-dropzone.dragover {
  border-color: var(--telemetry-cyan);
  background: rgba(14, 165, 233, 0.08);
}

.dropzone-Prompt {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  cursor: pointer;
}

.dropzone-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: rgba(14, 165, 233, 0.15);
  color: var(--telemetry-cyan);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  font-weight: 700;
  flex-shrink: 0;
}

.dropzone-text {
  display: flex;
  flex-direction: column;
  font-size: 0.88rem;
  min-width: 0;
}

.dropzone-text span {
  font-size: 0.76rem;
  color: var(--text-secondary);
}

.text-source-pane {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.tx-textarea,
.rx-data-textarea {
  width: 100%;
  min-width: 0;
  background: var(--bg-console);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 0.6rem 0.7rem;
  border-radius: 7px;
  font-size: 0.84rem;
  line-height: 1.5;
  resize: vertical;
}

.tx-textarea:focus,
.rx-data-textarea:focus {
  outline: none;
  border-color: var(--border-focus);
}

.text-source-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.text-filename-group {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.78rem;
  color: var(--text-secondary);
  flex-wrap: wrap;
  flex: 1;
  min-width: 0;
}

.text-filename-group input {
  width: 165px;
  max-width: 100%;
  padding: 0.32rem 0.55rem;
  font-size: 0.8rem;
}

.text-byte-hint {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--telemetry-cyan);
}

.file-summary {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding-top: 0.55rem;
  border-top: 1px solid var(--border-subtle);
}

.file-meta-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.file-name {
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--text-primary);
  word-break: break-all;
}

.file-badge {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  background: var(--bg-console);
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  color: var(--telemetry-cyan);
  border: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.file-meta-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
  align-items: center;
}

.file-meta-stats code {
  font-family: var(--font-mono);
  color: var(--signal-amber);
}

.btn-link {
  background: none;
  border: none;
  color: var(--telemetry-cyan);
  cursor: pointer;
  font-size: 0.8rem;
  text-decoration: underline;
}

/* ==================== Optical Stage & Sender Controls ==================== */
.optical-stage-wrapper {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
  min-width: 0;
}

@media (max-width: 820px) {
  .optical-stage-wrapper {
    grid-template-columns: minmax(0, 1fr);
  }
}

.optical-stage {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 0.8rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  max-width: 350px;
  margin: 0 auto;
}

.carousel-progress-track {
  width: 100%;
  height: 4px;
  background: var(--bg-console);
  border-radius: 2px;
  overflow: hidden;
}

.carousel-progress-bar {
  height: 100%;
  width: 0%;
  background: var(--signal-amber);
  transition: width 0.08s linear;
}

.qr-canvas-container {
  position: relative;
  background: var(--optical-white);
  padding: 10px;
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 310px;
  aspect-ratio: 1 / 1;
}

#qrCanvas {
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  display: block;
}

.qr-empty-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 20, 28, 0.92);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1.25rem;
  border-radius: 8px;
  font-size: 0.85rem;
}

.stage-telemetry {
  width: 100%;
  background: var(--bg-console);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 0.5rem 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.telemetry-primary {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

.telemetry-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.telemetry-index {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--signal-amber);
}

.telemetry-secondary {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* ==================== Control Cards ==================== */
.controls-column,
.rx-controls-column {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  min-width: 0;
  width: 100%;
}

.control-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  min-width: 0;
  width: 100%;
}

.control-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.control-card-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.playback-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.param-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.6rem;
}

.param-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.78rem;
  color: var(--text-secondary);
  min-width: 0;
}

.input-with-unit {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.input-with-unit em {
  font-style: normal;
  font-size: 0.7rem;
  color: var(--text-muted);
}

input[type="number"],
input[type="text"],
select {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  background: var(--bg-console);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 0.45rem 0.6rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-family: var(--font-sans);
}

input[type="number"]:focus,
input[type="text"]:focus,
select:focus {
  outline: none;
  border-color: var(--border-focus);
}

.mono-input {
  font-family: var(--font-mono) !important;
}

/* ==================== Buttons & Pills ==================== */
.btn {
  border: 1px solid transparent;
  padding: 0.48rem 0.8rem;
  border-radius: 6px;
  font-size: 0.83rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  transition: all 0.15s ease;
  text-align: center;
  max-width: 100%;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-sm {
  padding: 0.34rem 0.65rem;
  font-size: 0.78rem;
}

.btn-primary {
  background: var(--signal-amber);
  color: #0f141c;
}

.btn-primary:hover:not(:disabled) {
  background: #fbbf24;
}

.btn-primary.playing {
  background: var(--danger-rose);
  color: #fff;
}

.btn-secondary {
  background: var(--bg-console);
  color: var(--text-primary);
  border-color: var(--border-subtle);
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--text-secondary);
}

.btn-accent {
  background: rgba(14, 165, 233, 0.16);
  color: #38bdf8;
  border-color: rgba(14, 165, 233, 0.4);
}

.btn-accent:hover:not(:disabled) {
  background: rgba(14, 165, 233, 0.26);
}

.btn-accent.active-loopback,
.btn-accent.playing {
  background: var(--danger-rose);
  color: #fff;
  border-color: var(--danger-rose);
}

.btn-success {
  background: var(--verified-emerald);
  color: #06281e;
  font-weight: 700;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-subtle);
}

.btn-ghost:hover:not(:disabled) {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.04);
}

.mode-pills {
  display: flex;
  background: var(--bg-console);
  padding: 2px;
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
}

.pill-btn {
  background: transparent;
  color: var(--text-secondary);
  border: none;
  padding: 0.25rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
}

.pill-btn.active {
  background: var(--telemetry-cyan);
  color: #0f141c;
}

.range-input-row {
  display: flex;
  gap: 0.45rem;
  min-width: 0;
}

.range-input-row input {
  flex: 1;
  min-width: 0;
}

.range-input-row .btn {
  flex-shrink: 0;
}

.range-Quick-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.range-quick-btns {
  display: flex;
  gap: 0.35rem;
}

.btn-tiny {
  background: var(--bg-console);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 0.18rem 0.5rem;
  font-size: 0.72rem;
  cursor: pointer;
}

.btn-tiny:hover:not(:disabled) {
  color: var(--text-primary);
  border-color: var(--text-secondary);
}

/* ==================== Chunk Matrix ==================== */
.matrix-section {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  min-width: 0;
}

.matrix-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.81rem;
  font-weight: 600;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.matrix-header small {
  font-weight: 400;
  color: var(--text-secondary);
}

.matrix-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  font-size: 0.74rem;
  color: var(--text-secondary);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 2px;
  display: inline-block;
}

.dot-active {
  background: var(--signal-amber);
}
.dot-queued {
  background: var(--telemetry-cyan);
}
.dot-skipped {
  background: #334155;
}
.dot-received {
  background: var(--verified-emerald);
}
.dot-missing {
  background: #334155;
}

.chunk-matrix {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(42px, 1fr));
  gap: 0.35rem;
  max-height: 190px;
  overflow-y: auto;
  padding: 0.2rem;
}

.matrix-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 1.1rem;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.chunk-cell {
  font-family: var(--font-mono);
  font-size: 0.73rem;
  font-weight: 600;
  padding: 0.32rem 0.15rem;
  border-radius: 5px;
  text-align: center;
  border: 1px solid var(--border-subtle);
  background: var(--bg-console);
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  transition: transform 0.1s, border-color 0.1s, background-color 0.1s;
}

.chunk-cell:hover {
  border-color: var(--text-secondary);
}

.chunk-cell.queued {
  background: rgba(14, 165, 233, 0.18);
  color: #7dd3fc;
  border-color: rgba(14, 165, 233, 0.45);
}

.chunk-cell.current {
  background: var(--signal-amber) !important;
  color: #0f141c !important;
  border-color: #fde68a !important;
  font-weight: 700;
  transform: scale(1.05);
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.5);
}

.chunk-cell.received {
  background: rgba(16, 185, 129, 0.22);
  color: #6ee7b7;
  border-color: rgba(16, 185, 129, 0.5);
  cursor: default;
}

.chunk-cell.just-scanned {
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.85);
  border-color: #fff;
}

/* ==================== Receiver Camera & Telemetry ==================== */
.receiver-top-grid {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
  min-width: 0;
}

@media (max-width: 820px) {
  .receiver-top-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.camera-stage {
  position: relative;
  width: 100%;
  max-width: 350px;
  aspect-ratio: 4 / 3;
  min-height: 230px;
  margin: 0 auto;
  background: #070a0f;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

#rxVideo,
#rxCropStageCanvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.crop-active-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(14, 165, 233, 0.92);
  color: #082f49;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.16rem 0.55rem;
  border-radius: 999px;
  z-index: 5;
  pointer-events: none;
}

.screen-crop-tools {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.screen-crop-tools .btn {
  flex: 1;
}

.camera-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.1rem;
  text-align: center;
  color: var(--text-secondary);
  gap: 0.4rem;
  background: rgba(15, 20, 28, 0.88);
}

.camera-icon {
  font-size: 1.85rem;
}

.camera-placeholder p {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-primary);
}

.camera-placeholder small {
  font-size: 0.74rem;
  color: var(--text-muted);
}

.scan-reticle {
  position: absolute;
  inset: 22px;
  pointer-events: none;
}

.reticle-corner {
  position: absolute;
  width: 22px;
  height: 22px;
  border-color: var(--verified-emerald);
  border-style: solid;
  border-width: 0;
}

.reticle-corner.tl {
  top: 0;
  left: 0;
  border-top-width: 3px;
  border-left-width: 3px;
}
.reticle-corner.tr {
  top: 0;
  right: 0;
  border-top-width: 3px;
  border-right-width: 3px;
}
.reticle-corner.bl {
  bottom: 0;
  left: 0;
  border-bottom-width: 3px;
  border-left-width: 3px;
}
.reticle-corner.br {
  bottom: 0;
  right: 0;
  border-bottom-width: 3px;
  border-right-width: 3px;
}

.scan-laser {
  position: absolute;
  left: 6px;
  right: 6px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--verified-emerald), transparent);
  top: 50%;
  opacity: 0.35;
}

.camera-stage.scanning .scan-laser {
  opacity: 0.9;
  animation: laserSweep 2s infinite ease-in-out;
}

@keyframes laserSweep {
  0%, 100% { top: 12%; }
  50% { top: 88%; }
}

.scan-toast {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(16, 185, 129, 0.92);
  color: #042f2e;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 700;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  white-space: nowrap;
}

.rx-action-stack {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 0;
}

.camera-select-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: var(--text-secondary);
  min-width: 0;
}

.camera-select-row label {
  flex-shrink: 0;
}

.camera-select-row select {
  flex: 1;
  min-width: 0;
  text-overflow: ellipsis;
}

.divider-text {
  display: flex;
  align-items: center;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.72rem;
  margin: 0.1rem 0;
}

.divider-text::before,
.divider-text::after {
  content: "";
  flex: 1;
  border-bottom: 1px solid var(--border-subtle);
}

.divider-text span {
  padding: 0 0.5rem;
}

.file-upload-btn {
  cursor: pointer;
}

.rx-progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.rx-file-title {
  font-weight: 600;
  font-size: 0.86rem;
  word-break: break-all;
  min-width: 0;
}

.rx-percent {
  font-family: var(--font-mono);
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--verified-emerald);
  flex-shrink: 0;
}

.rx-progress-bar-track {
  width: 100%;
  height: 8px;
  background: var(--bg-console);
  border-radius: 99px;
  overflow: hidden;
}

.rx-progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--telemetry-cyan), var(--verified-emerald));
  transition: width 0.2s ease;
}

.rx-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
}

.stat-box {
  background: var(--bg-console);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 0.42rem 0.55rem;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.stat-label {
  font-size: 0.71rem;
  color: var(--text-muted);
}

.stat-val {
  font-family: var(--font-mono);
  font-size: 0.81rem;
  color: var(--text-primary);
  word-break: break-all;
}

.missing-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.missing-subtitle {
  display: block;
  font-size: 0.74rem;
  color: var(--text-secondary);
}

.missing-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.missing-output {
  width: 100%;
  color: var(--signal-amber) !important;
}

.rx-data-card.highlight-focus {
  animation: cardPulseFocus 1.8s ease-out;
}

@keyframes cardPulseFocus {
  0% {
    border-color: var(--verified-emerald);
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.35);
  }
  100% {
    border-color: var(--border-subtle);
    box-shadow: none;
  }
}

.rx-data-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.rx-data-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.rx-data-badge {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: var(--bg-console);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

.rx-data-badge.ready {
  background: rgba(16, 185, 129, 0.18);
  color: var(--verified-emerald);
  border-color: rgba(16, 185, 129, 0.45);
}

.rx-data-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.complete-banner {
  background: rgba(16, 185, 129, 0.14);
  border: 1px solid rgba(16, 185, 129, 0.5);
  border-radius: 8px;
  padding: 0.65rem 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.complete-info {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
  flex: 1;
}

.complete-icon {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--verified-emerald);
  color: #042f2e;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
}

.complete-info strong {
  font-size: 0.84rem;
  display: block;
}

.complete-info p {
  font-size: 0.76rem;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  word-break: break-all;
}

/* ==================== Received History List ==================== */
.rx-history-section {
  border-top: 1px solid var(--border-subtle);
  padding-top: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.rx-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.rx-history-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  max-height: 280px;
  overflow-y: auto;
}

.rx-history-item {
  background: var(--bg-console);
  border: 1px solid var(--border-subtle);
  border-radius: 7px;
  padding: 0.6rem 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.rx-history-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.rx-history-meta {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
  font-size: 0.78rem;
  min-width: 0;
}

.rx-history-seq {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  background: rgba(16, 185, 129, 0.18);
  color: var(--verified-emerald);
  padding: 0.1rem 0.42rem;
  border-radius: 4px;
}

.rx-history-name {
  font-weight: 600;
  color: var(--text-primary);
  word-break: break-all;
}

.rx-history-sub {
  font-family: var(--font-mono);
  font-size: 0.71rem;
  color: var(--text-muted);
}

.rx-history-btns {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.rx-history-preview {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 5px;
  padding: 0.4rem 0.55rem;
  max-height: 76px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ==================== Screenshot Region Crop Modal ==================== */
.crop-modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(7, 10, 15, 0.94);
  display: flex;
  flex-direction: column;
  user-select: none;
}

.crop-modal-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem 1.25rem;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border-subtle);
  gap: 1rem;
  flex-wrap: wrap;
}

.crop-modal-tip {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-size: 0.86rem;
  color: var(--text-primary);
}

.crop-badge {
  background: var(--telemetry-cyan);
  color: #082f49;
  font-weight: 700;
  font-size: 0.76rem;
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
}

.crop-modal-actions {
  display: flex;
  gap: 0.5rem;
}

.crop-modal-body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  overflow: hidden;
}

.crop-canvas-stage {
  position: relative;
  display: inline-flex;
  max-width: 96vw;
  max-height: calc(100vh - 80px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.65);
  border: 1px solid var(--border-subtle);
  cursor: crosshair;
}

#cropSelectorCanvas {
  display: block;
  max-width: 96vw;
  max-height: calc(100vh - 80px);
  width: auto;
  height: auto;
}

.crop-selection-box {
  position: absolute;
  border: 2px solid var(--telemetry-cyan);
  background: rgba(14, 165, 233, 0.12);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.58);
  pointer-events: none;
}

.crop-size-tag {
  position: absolute;
  top: -26px;
  left: 0;
  background: var(--telemetry-cyan);
  color: #082f49;
  font-family: var(--font-mono);
  font-size: 0.73rem;
  font-weight: 700;
  padding: 0.12rem 0.45rem;
  border-radius: 4px;
  white-space: nowrap;
}

/* ==================== Notification Toast ==================== */
.notification-banner {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  left: auto;
  background: #1e293b;
  color: var(--text-primary);
  border-left: 4px solid var(--telemetry-cyan);
  padding: 0.7rem 1rem;
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  font-size: 0.84rem;
  z-index: 1000;
  max-width: min(420px, calc(100vw - 2rem));
}

/* ==================== Mobile Responsive Refinements ==================== */
@media (max-width: 640px) {
  .topbar {
    padding: 0.65rem 0.75rem;
    gap: 0.6rem;
  }

  .brand-subtitle {
    display: none;
  }

  .view-switcher {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .tab-btn {
    padding: 0.42rem 0.35rem;
    font-size: 0.79rem;
  }

  .workspace {
    padding: 0.6rem;
    gap: 0.75rem;
  }

  .panel {
    padding: 0.75rem;
    gap: 0.75rem;
    border-radius: 10px;
  }

  .panel-header {
    gap: 0.45rem;
  }

  .panel-title-group h2 {
    font-size: 0.94rem;
  }

  .optical-stage {
    padding: 0.65rem;
    max-width: 100%;
  }

  .qr-canvas-container {
    max-width: 270px;
    padding: 8px;
  }

  .camera-stage {
    max-width: 100%;
    aspect-ratio: 1 / 1;
    min-height: 240px;
  }

  .playback-buttons {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.4rem;
  }

  .playback-buttons .btn-play {
    grid-column: 1 / -1;
    padding: 0.55rem;
  }

  .param-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .param-grid .param-field:last-child {
    grid-column: 1 / -1;
  }

  .range-input-row {
    flex-direction: column;
  }

  .range-input-row .btn {
    width: 100%;
  }

  .text-source-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .text-filename-group {
    justify-content: space-between;
  }

  .text-filename-group input {
    flex: 1;
    width: auto;
  }

  .text-source-toolbar .btn {
    width: 100%;
  }

  .missing-actions,
  .rx-data-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .complete-banner #btnReceiveNext {
    width: 100%;
  }

  .rx-history-btns {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  /* Hide single-machine split loopback and desktop screen capture on mobile single-panel receiver view */
  .workspace.mode-receiver #btnToggleLoopback,
  .workspace.mode-receiver #btnToggleScreenCapture,
  .workspace.mode-receiver .divider-text {
    display: none;
  }

  .notification-banner {
    left: 0.75rem;
    right: 0.75rem;
    bottom: 0.75rem;
    max-width: none;
  }
}
