/* WitBlox OLED — hide code export, connection & hardware settings only */

.witblox-app #configArea,
.witblox-app #wiringCard,
.witblox-app #getCodeBtn,
.witblox-app #hwModal,
.witblox-app #wifiModal,
.witblox-app #codeModal,
.witblox-app #oledBoard2,
.witblox-app #templateTargetRow,
.witblox-app .header-controls,
.witblox-app #whatsNewModal {
  display: none !important;
}

.witblox-app #header {
  justify-content: space-between;
}

.witblox-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex-shrink: 0;
}

.header-live-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1.5px solid rgba(255, 255, 255, 0.35);
  background: rgba(15, 23, 42, 0.35);
  color: rgba(248, 250, 252, 0.85);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.18s ease;
}

.header-live-btn:hover:not(:disabled) {
  border-color: rgba(255, 255, 255, 0.55);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

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

.header-live-btn.is-active {
  border-color: #22c55e;
  background: rgba(34, 197, 94, 0.2);
  color: #fff;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.25);
}

.header-live-btn__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(248, 250, 252, 0.45);
  flex-shrink: 0;
}

.header-live-btn.is-active .header-live-btn__dot {
  background: #22c55e;
  box-shadow: 0 0 8px #22c55e;
  animation: livePulse 1.2s ease-in-out infinite;
}

@keyframes livePulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.65; transform: scale(0.92); }
}

.live-connect-modal {
  position: fixed;
  inset: 0;
  z-index: 10050;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.live-connect-modal[hidden] {
  display: none !important;
}

.live-connect-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
}

.live-connect-modal__panel {
  position: relative;
  width: min(380px, 100%);
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
  padding: 18px 18px 16px;
}

.live-connect-modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.live-connect-modal__head h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.live-connect-modal__close {
  border: none;
  background: none;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  padding: 0 4px;
}

.live-connect-modal__hint {
  margin: 0 0 14px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
}

.live-connect-modal__field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

.live-connect-modal__field > span {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.live-connect-modal__input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
}

.live-connect-modal__input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 107, 0, 0.15);
}

.live-connect-modal__input.is-invalid {
  border-color: var(--danger, #dc2626);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12);
}

.live-connect-modal__input.is-invalid:focus {
  border-color: var(--danger, #dc2626);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.15);
}

.live-connect-modal__status {
  min-height: 18px;
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.live-connect-modal__status.is-ok { color: #16a34a; }
.live-connect-modal__status.is-err { color: var(--danger, #dc2626); }

.live-connect-modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.live-connect-modal__btn {
  padding: 9px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
}

.live-connect-modal__btn--ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.live-connect-modal__btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.live-connect-modal__btn--primary:hover:not(:disabled) {
  filter: brightness(1.05);
}

.live-connect-modal__btn--primary:disabled {
  opacity: 0.6;
  cursor: wait;
}

.witblox-app .site-tagline,
.witblox-app .witblox-hw-badge {
  display: none !important;
}

.witblox-app #oledBoard .pcb-label:first-child::after {
  content: ' · 0.96"';
}

/* Icons8 gallery — center grid and tabs in the left panel */
.witblox-app #iconGrid {
  justify-content: center;
}

.witblox-app #catTabs {
  justify-content: center;
  flex-wrap: wrap;
}

.witblox-app #gallerySearchBox {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.witblox-app #gallerySearchBox .gallery-search-row {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
  max-width: 560px;
}

.witblox-app #gallerySearchBox #tplSearch {
  width: 100%;
  max-width: none;
}

.witblox-app #gallerySearchBox .icons8-bar {
  width: auto;
  max-width: none;
  flex: 0 0 auto;
  margin-top: 0;
}

@media (max-width: 768px) {
  .witblox-app #galleryView {
    background: transparent;
  }

  .witblox-app #gallerySearchBox {
    padding: 8px 12px 10px;
    align-items: center;
    flex-direction: row;
    flex-wrap: nowrap;
    background: transparent;
  }

  .witblox-app #gallerySearchBox .gallery-search-row {
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
    max-width: none;
  }

  .witblox-app #gallerySearchBox #tplSearch {
    width: 100%;
    max-width: none;
  }

  .witblox-app #gallerySearchBox .icons8-bar {
    width: auto;
    max-width: none;
    flex: 0 0 auto;
    margin-top: 0;
  }

  .witblox-app #catTabs {
    justify-content: flex-start;
    flex-wrap: nowrap;
    padding: 0 12px 12px;
    background: transparent;
    border-bottom: none;
  }

  .witblox-app #iconGrid {
    padding: 4px 12px 20px;
    gap: 10px;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    justify-content: stretch;
    background: transparent;
  }

  .witblox-app .icon-card {
    width: 100%;
    max-width: none;
    padding: 0 0 100%;
    height: 0;
    border: none;
    background: transparent;
    box-shadow: none;
    display: block;
    position: relative;
    overflow: visible;
  }

  .witblox-app .icon-card span {
    display: none;
  }

  .witblox-app .icon-card:hover,
  .witblox-app .icon-card.selected {
    border: none;
    background: transparent;
    box-shadow: none;
  }

  .witblox-app .icons8-card {
    min-height: 0;
  }

  .witblox-app .icon-card canvas,
  .witblox-app .icons8-lottie-thumb {
    border-radius: 14px;
    border: 1.5px solid #e2e8f0;
    background: #fff;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
  }

  .witblox-app .icon-card.selected canvas,
  .witblox-app .icon-card.selected .icons8-lottie-thumb {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(255, 107, 0, 0.22), 0 4px 12px rgba(255, 107, 0, 0.18);
  }

  .witblox-app .icons8-lottie-thumb svg {
    width: 82% !important;
    height: 82% !important;
  }

  .witblox-app .icons8-card:hover .icons8-lottie-thumb {
    border-color: #cbd5e1;
  }

  .witblox-app .oled-board-unit {
    border-radius: 18px;
  }
}

/* ── Flow Mode (React Flow — full width) ─────────────────────────────────── */
#main.is-flow-mode {
  grid-template-columns: 1fr;
  grid-template-rows: auto 1fr;
}

#main.is-flow-mode #modeBar {
  grid-column: 1;
  grid-row: 1;
}

#main.is-flow-mode #right {
  display: none !important;
}

#main.is-flow-mode #left {
  grid-column: 1;
  grid-row: 2;
  width: 100%;
  max-width: none;
  border-right: none;
}

#flowView {
  display: none;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: #f4f6f8;
  width: 100%;
}

#flowView.is-visible {
  display: flex;
  flex-direction: column;
}

#flowReactRoot {
  flex: 1;
  width: 100%;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.flow-workspace {
  display: flex;
  flex: 1;
  min-height: 0;
  width: 100%;
  height: 100%;
}

.flow-sidebar {
  width: 200px;
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid var(--border);
  padding: 14px 12px;
  overflow-y: auto;
}
.flow-sidebar__head {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 8px;
}
.flow-sidebar__hint {
  font-size: 11px;
  color: var(--muted);
  margin: 0 0 10px;
  line-height: 1.4;
}
.flow-sidebar__divider {
  height: 1px;
  background: var(--border);
  margin: 14px 0;
}
.flow-palette-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 10px;
  margin-bottom: 6px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}
.flow-palette-item:hover {
  border-color: var(--accent);
  background: var(--accent-light);
}
.flow-palette-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.flow-palette-dot--gpio { background: #0d9488; }
.flow-palette-dot--play { background: #ff6b00; }
.flow-palette-dot--default { background: #8b5cf6; }
.flow-palette-dot--message { background: #2563eb; }
.flow-palette-dot--timer { background: #d97706; }
.flow-palette-dot--repeat { background: #7c3aed; }

.flow-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.flow-react-canvas {
  flex: 1;
  min-height: 0;
  width: 100%;
  height: 100%;
}

.flow-canvas-wrap {
  flex: 1;
  position: relative;
  overflow: auto;
  min-height: 0;
}
.flow-canvas {
  position: relative;
  min-width: 1200px;
  min-height: 700px;
  background-color: #fafbfc;
  background-image: radial-gradient(circle, #c5cdd8 1px, transparent 1px);
  background-size: 18px 18px;
}
.flow-edges {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
}
.flow-edge {
  fill: none;
  stroke: #94a3b8;
  stroke-width: 2.5;
}
.flow-edge.is-active { stroke: #0d9488; }

/* Nodes */
.flow-node {
  position: absolute;
  width: 220px;
  background: #fff;
  border: 2px solid #e2e8f0;
  border-radius: 14px;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.08);
  user-select: none;
  z-index: 2;
}
.flow-node.is-selected { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255, 107, 0, 0.2); }
.flow-node.is-dragging { opacity: 0.92; cursor: grabbing; }

.flow-node--start {
  width: 160px;
  border-color: #c4b5fd;
  background: #fff;
  padding: 12px;
}
.flow-node__start-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #7c3aed, #a855f7);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  cursor: default;
  pointer-events: none;
}

.flow-node__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: 12px 12px 0 0;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  cursor: grab;
}
.flow-node__head:active { cursor: grabbing; }
.flow-node__head--gpio { background: #0d9488; }
.flow-node__head--play { background: #ff6b00; }
.flow-node__head--default { background: #7c3aed; }
.flow-node__del {
  background: rgba(255,255,255,0.2);
  border: none;
  color: #fff;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
}
.flow-node__del:hover { background: rgba(255,255,255,0.35); }

.flow-node__body { padding: 12px; }
.flow-field {
  margin-bottom: 10px;
}
.flow-field:last-child { margin-bottom: 0; }
.flow-field label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 4px;
}
.flow-field select {
  width: 100%;
  padding: 7px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
  background: #fff;
  color: var(--text);
}

.flow-port {
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid #0d9488;
  z-index: 10;
  cursor: crosshair;
  box-shadow: 0 0 0 2px rgba(13, 148, 136, 0.15);
}
.flow-port:hover, .flow-port.is-hot {
  border-color: #ff6b00;
  background: #fff7ed;
  transform: scale(1.2);
}
.flow-port--in { left: -10px; top: 50%; margin-top: -9px; }
.flow-port--then { right: -10px; top: 38%; }
.flow-port--else { right: -10px; top: 62%; }
.flow-port-label {
  position: absolute;
  right: 12px;
  font-size: 9px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
}
.flow-port-label--then { top: 34%; }
.flow-port-label--else { top: 58%; }

.flow-ip-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
  margin-bottom: 8px;
  box-sizing: border-box;
}
.flow-connect-row--stack { flex-direction: column; }
.flow-btn {
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.flow-btn--block { width: 100%; }
.flow-btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.flow-run-btn {
  padding: 10px 22px;
  border: none;
  border-radius: 10px;
  background: #22c55e;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(34, 197, 94, 0.35);
}
.flow-run-btn:hover { background: #16a34a; }

.flow-send-oled-btn {
  padding: 10px 24px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(255, 107, 0, 0.35);
}
.flow-send-oled-btn:hover { background: #e55f00; }

.flow-send-oled-btn--sidebar {
  display: block;
  width: 100%;
  margin-top: 8px;
}

.flow-pick-anim {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  width: 100%;
  padding: 8px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: #f8fafc;
  cursor: pointer;
  text-align: left;
}
.flow-pick-anim:hover { border-color: var(--accent); background: #fff7ed; }
.flow-pick-thumb {
  width: 100%;
  height: auto;
  border-radius: 4px;
  background: #000;
  image-rendering: pixelated;
}
.flow-pick-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}
.flow-pick-change {
  font-size: 10px;
  font-weight: 700;
  color: var(--accent);
}

.flow-anim-modal[hidden],
.flow-anim-modal--hidden { display: none !important; }
.flow-anim-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}
.flow-anim-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
}
.flow-anim-modal__panel {
  position: relative;
  width: min(720px, 92vw);
  max-height: min(80vh, 100dvh);
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.flow-anim-modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 15px;
  flex-shrink: 0;
}
.flow-anim-modal__close {
  border: none;
  background: transparent;
  font-size: 18px;
  cursor: pointer;
  color: var(--muted);
}
.flow-anim-modal__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.flow-anim-modal__hint {
  margin: 0;
  padding: 10px 18px 0;
  font-size: 12px;
  color: var(--muted);
}
.flow-anim-modal__panel--wide {
  width: min(960px, 96vw);
  max-height: min(88vh, 100dvh);
}

.flow-anim-modal__sources {
  display: flex;
  gap: 8px;
  padding: 12px 18px 0;
}

.flow-anim-modal__source {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  color: var(--muted);
}

.flow-anim-modal__source.is-active,
.flow-anim-modal__source:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: #fff7ed;
}

.flow-anim-modal__toolbar {
  padding: 10px 18px 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.flow-anim-modal__search-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.flow-anim-modal__search-done {
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  padding: 10px 12px;
  cursor: pointer;
}

.flow-anim-modal__search {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  box-sizing: border-box;
}

.flow-anim-modal__cats {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 2px;
}

.flow-anim-modal__cats::-webkit-scrollbar {
  display: none;
}

.flow-anim-modal__cat {
  flex-shrink: 0;
  white-space: nowrap;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  color: var(--muted);
}

.flow-anim-modal__cat.is-active,
.flow-anim-modal__cat:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: #fff7ed;
}

.flow-anim-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 12px;
  padding: 16px 18px 20px;
  align-content: start;
  /* Scroll lives on .flow-anim-modal__body — grid must not stretch cards */
  overflow: visible;
  flex: none;
  min-height: 0;
}
.flow-anim-grid__spacer {
  grid-column: 1 / -1;
  width: 100%;
  pointer-events: none;
}
.flow-anim-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  text-align: left;
  align-self: start;
  height: auto;
}
.flow-anim-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(255, 107, 0, 0.15);
}
.flow-anim-card__thumb {
  width: 100%;
  height: auto;
  border-radius: 4px;
  background: #000;
  image-rendering: pixelated;
}
.flow-anim-card__thumb.flow-anim-card__thumb--lottie,
.rf-pick-thumb.rf-pick-thumb--lottie:not(.rf-pick-thumb--compact) {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--border);
  image-rendering: auto;
}
.flow-anim-card__thumb.flow-anim-card__thumb--lottie svg,
.rf-pick-thumb.rf-pick-thumb--lottie:not(.rf-pick-thumb--compact) svg {
  width: 88% !important;
  height: 88% !important;
}
.flow-anim-card__thumb.flow-anim-card__thumb--lottie.is-loading::after,
.rf-pick-thumb.rf-pick-thumb--lottie.is-loading::after {
  content: '…';
  color: #64748b;
  font-size: 18px;
}
.flow-anim-card:hover .flow-anim-card__thumb--lottie {
  border-color: var(--accent);
  background: #fff7ed;
}
.flow-anim-card__name {
  font-size: 11px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text);
}
.flow-anim-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 24px;
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 768px) {
  .flow-anim-modal {
    align-items: stretch;
  }

  .flow-anim-modal__panel,
  .flow-anim-modal__panel--wide {
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
  }

  .flow-anim-modal__body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .flow-anim-grid {
    overflow: visible;
    flex: none;
  }

  .flow-anim-modal--search-focus {
    top: var(--modal-vvt, 0px);
    height: var(--modal-vvh, 100dvh);
  }

  .flow-anim-modal--search-focus .flow-anim-modal__panel {
    height: 100%;
    max-height: 100%;
  }

  .flow-anim-modal--search-focus .flow-anim-modal__head,
  .flow-anim-modal--search-focus .flow-anim-modal__sources,
  .flow-anim-modal--search-focus .flow-anim-modal__hint,
  .flow-anim-modal--search-focus .flow-anim-modal__cats {
    display: none;
  }

  .flow-anim-modal--search-focus .flow-anim-modal__toolbar {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #fff;
    padding-top: max(10px, env(safe-area-inset-top));
    border-bottom: 1px solid var(--border);
  }
}

/* Flow mobile / short screen — fill viewport, don’t spill below */
body.flow-mobile.flow-anim-picker-open .flow-anim-modal {
  align-items: stretch;
  z-index: 100001;
}

body.flow-mobile.flow-anim-picker-open .flow-anim-modal__panel,
body.flow-mobile.flow-anim-picker-open .flow-anim-modal__panel--wide {
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: 100%;
  border-radius: 0;
}

/* Phone landscape / short viewport: denser grid so more icons fit + scroll */
@media (max-height: 520px) {
  .flow-anim-modal {
    align-items: stretch;
  }

  .flow-anim-modal__panel,
  .flow-anim-modal__panel--wide {
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
  }

  .flow-anim-modal__head {
    padding: 8px 12px;
    font-size: 13px;
    flex-shrink: 0;
  }

  .flow-anim-modal__sources {
    padding: 6px 10px 0;
  }

  .flow-anim-modal__source {
    padding: 6px 8px;
    font-size: 12px;
  }

  .flow-anim-modal__toolbar {
    padding: 6px 10px 0;
  }

  .flow-anim-modal__search {
    padding: 8px 10px;
    font-size: 12px;
  }

  .flow-anim-modal__cats {
    padding: 6px 0 4px;
  }

  .flow-anim-modal__cat {
    padding: 4px 10px;
    font-size: 11px;
  }

  .flow-anim-modal__hint {
    display: none;
  }

  .flow-anim-grid {
    overflow: visible;
    flex: none;
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
    gap: 8px;
    padding: 8px 10px 20px;
  }

  .flow-anim-card {
    padding: 6px;
    gap: 4px;
  }

  .flow-anim-card__name {
    font-size: 10px;
    line-height: 1.2;
  }

  .flow-anim-card__thumb.flow-anim-card__thumb--lottie,
  .rf-pick-thumb.rf-pick-thumb--lottie:not(.rf-pick-thumb--compact) {
    height: 44px;
  }
}

body.flow-mobile.flow-anim-search-active .flow-anim-modal {
  top: var(--modal-vvt, 0px);
  height: var(--modal-vvh, 100dvh);
}

body.flow-mobile.flow-anim-search-active .flow-anim-modal__panel {
  height: var(--modal-vvh, 100dvh);
  max-height: var(--modal-vvh, 100dvh);
}

body.flow-mobile.flow-anim-search-active .flow-anim-modal__head,
body.flow-mobile.flow-anim-search-active .flow-anim-modal__sources,
body.flow-mobile.flow-anim-search-active .flow-anim-modal__hint,
body.flow-mobile.flow-anim-search-active .flow-anim-modal__cats {
  display: none;
}

body.flow-mobile.flow-anim-search-active .flow-anim-modal__toolbar {
  position: sticky;
  top: 0;
  z-index: 2;
  flex-shrink: 0;
  background: #fff;
  padding: 6px 10px 8px;
  border-bottom: 1px solid var(--border);
}

body.flow-mobile.flow-anim-search-active .flow-anim-modal__search {
  padding: 8px 10px;
  font-size: 12px;
}

body.flow-mobile.flow-anim-search-active .flow-anim-modal__search-done {
  padding: 8px 10px;
}

body.flow-mobile.flow-anim-search-active .flow-anim-grid {
  overflow: visible;
  flex: none;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 8px;
  padding: 8px 10px 12px;
}

body.flow-mobile.flow-anim-search-active .flow-anim-card {
  padding: 6px;
  gap: 4px;
}

body.flow-mobile.flow-anim-search-active .flow-anim-card__name {
  display: none;
}

.flow-conn-status {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  margin-top: 6px;
}
.flow-conn-status.is-online { color: #22c55e; }

.flow-gpio-bar--compact {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.flow-gpio-bar--compact .flow-gpio-pin {
  padding: 8px 6px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 10px;
  text-align: center;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 2px;
  line-height: 1.2;
}
.flow-gpio-pin__label {
  display: block;
  font-weight: 800;
  font-size: 13px;
  color: var(--text);
}
.flow-gpio-pin__role {
  display: block;
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.flow-gpio-pin__state {
  display: block;
  font-weight: 700;
  font-size: 11px;
  margin-top: 2px;
}
.flow-gpio-bar--compact .flow-gpio-pin span { display: block; font-weight: 700; }
.flow-gpio-bar--compact .flow-gpio-pin b { font-weight: 600; color: var(--muted); }
.flow-gpio-pin.is-high {
  border-color: #86efac;
  background: #f0fdf4;
}
.flow-gpio-pin.is-high .flow-gpio-pin__state { color: #16a34a; }
.flow-gpio-pin.is-low {
  border-color: #fdba74;
  background: #fff7ed;
}
.flow-gpio-pin.is-low .flow-gpio-pin__state { color: #ea580c; }

.flow-esp-details {
  margin-top: 10px;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #f8fafc;
  font-size: 10px;
}
.flow-esp-details__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.flow-esp-details__refresh {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 6px;
  width: 24px;
  height: 22px;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  color: var(--text);
}
.flow-esp-details__refresh:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}
.flow-esp-detail {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 0;
  border-bottom: 1px solid #e2e8f0;
  line-height: 1.3;
}
.flow-esp-detail:last-child { border-bottom: none; }
.flow-esp-detail > span {
  color: var(--muted);
  flex-shrink: 0;
}
.flow-esp-detail > b {
  text-align: right;
  font-weight: 600;
  color: var(--text);
  word-break: break-all;
}
.flow-esp-detail--flash {
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
}
.flow-esp-flash__bar {
  height: 5px;
  border-radius: 3px;
  background: #e2e8f0;
  overflow: hidden;
  margin: 2px 0;
}
.flow-esp-flash__fill {
  height: 100%;
  background: linear-gradient(90deg, #0d9488, #14b8a6);
  border-radius: 3px;
}
.flow-esp-flash b {
  font-size: 10px;
  font-weight: 600;
  color: var(--text);
}
.flow-esp-flash small {
  display: block;
  font-size: 9px;
  color: var(--muted);
}

.flow-deploy-status {
  padding: 8px 16px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  background: #fff;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.flow-deploy-status.is-ok { color: #22c55e; }
.flow-deploy-status.is-err { color: var(--danger); }

.flow-progress {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.flow-progress__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
}
.flow-progress__panel {
  position: relative;
  width: min(420px, 92vw);
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}
.flow-progress__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, #fff7ed, #fff);
}
.flow-progress__title {
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
}
.flow-progress__close {
  border: none;
  background: transparent;
  font-size: 18px;
  cursor: pointer;
  color: var(--muted);
}
.flow-progress__spinner {
  width: 18px;
  height: 18px;
  border: 2px solid #fed7aa;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: flowSpin 0.8s linear infinite;
}
@keyframes flowSpin { to { transform: rotate(360deg); } }
.flow-progress__steps {
  list-style: none;
  margin: 0;
  padding: 12px 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.flow-progress__step {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 4px 10px;
  align-items: start;
  font-size: 13px;
  color: var(--muted);
}
.flow-progress__step.is-active { color: var(--text); font-weight: 600; }
.flow-progress__step.is-done { color: #16a34a; }
.flow-progress__step.is-error { color: var(--danger); font-weight: 600; }
.flow-progress__icon {
  font-weight: 700;
  line-height: 1.3;
}
.flow-progress__step.is-active .flow-progress__icon {
  color: var(--accent);
  animation: flowPulse 1s ease-in-out infinite;
}
@keyframes flowPulse { 50% { opacity: 0.35; } }
.flow-progress__label { grid-column: 2; }
.flow-progress__detail {
  grid-column: 2;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
}
.flow-progress__step.is-active .flow-progress__detail { color: var(--accent); }

.flow-send-oled-btn:disabled,
.flow-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ── Flow mode — mobile landscape ─────────────────────────────────────────── */
.flow-rotate-hint {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100000;
  background: linear-gradient(165deg, #0f172a 0%, #1e293b 55%, #0f172a 100%);
  color: #f8fafc;
  align-items: center;
  justify-content: center;
  padding: 28px 24px;
  text-align: center;
}

.flow-rotate-hint:not([hidden]) {
  display: flex;
}

.flow-rotate-hint__inner {
  max-width: 280px;
}

.flow-rotate-hint__icon {
  font-size: 52px;
  line-height: 1;
  margin-bottom: 16px;
  animation: flowRotateHintWiggle 2s ease-in-out infinite;
}

.flow-rotate-hint__title {
  margin: 0 0 8px;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.flow-rotate-hint__text {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  color: #94a3b8;
}

.flow-rotate-hint__home {
  margin-top: 24px;
  padding: 12px 28px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  color: #f8fafc;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s, transform 0.15s;
}

.flow-rotate-hint__home:hover {
  background: rgba(255, 107, 0, 0.2);
  border-color: #ff6b00;
}

.flow-rotate-hint__home:active {
  transform: scale(0.97);
}

@keyframes flowRotateHintWiggle {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-14deg); }
  75% { transform: rotate(14deg); }
}

.flow-portrait-hint__icon {
  animation: flowPortraitHintWiggle 2s ease-in-out infinite;
}

@keyframes flowPortraitHintWiggle {
  0%, 100% { transform: rotate(90deg); }
  25% { transform: rotate(74deg); }
  75% { transform: rotate(106deg); }
}

body.flow-mode-active.flow-portrait-blocked #flowView {
  visibility: hidden;
  pointer-events: none;
}

/* Flow mode — mobile full height (JS .flow-mobile = any phone/tablet, incl. wide landscape) */
html.flow-mode-active.flow-mobile,
body.witblox-app.flow-mode-active.flow-mobile {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
}

body.witblox-app.flow-mode-active.flow-mobile {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  min-height: 100dvh;
  overflow: hidden;
}

body.witblox-app.flow-mode-active.flow-mobile .seo-footer {
  display: none !important;
}

body.witblox-app.flow-mode-active.flow-mobile #header {
  flex-shrink: 0;
  padding-top: max(6px, env(safe-area-inset-top));
  padding-bottom: 6px;
  padding-left: max(8px, env(safe-area-inset-left));
  padding-right: max(8px, env(safe-area-inset-right));
}

body.witblox-app.flow-mode-active.flow-mobile #main {
  flex: 1 !important;
  width: 100% !important;
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  overflow: hidden !important;
  display: flex;
  flex-direction: column;
}

body.witblox-app.flow-mode-active.flow-mobile #left {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0 !important;
  max-height: none !important;
  overflow: hidden;
  border-bottom: none;
}

body.witblox-app.flow-mode-active.flow-mobile #modeBar {
  order: -2;
  flex-shrink: 0;
  padding: 2px max(8px, env(safe-area-inset-left)) 4px;
  gap: 2px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 0;
  margin: 0;
  border: none;
  border-bottom: 1px solid var(--border);
  box-shadow: none;
}

body.witblox-app.flow-mode-active.flow-mobile .mode-btn {
  flex: 1 1 0;
  min-width: 0;
  min-height: 0 !important;
  padding: 6px 4px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  border-radius: 0;
  border: none !important;
  border-bottom: 2px solid transparent !important;
  background: transparent !important;
  box-shadow: none !important;
  color: var(--muted);
}

body.witblox-app.flow-mode-active.flow-mobile .mode-btn.active {
  color: var(--accent) !important;
  background: transparent !important;
  border-bottom-color: var(--accent) !important;
  box-shadow: none !important;
  font-weight: 800;
}

body.witblox-app.flow-mode-active.flow-mobile #flowView.is-visible {
  flex: 1;
  min-height: 0;
  width: 100%;
  height: auto;
  display: flex;
  flex-direction: column;
}

body.witblox-app.flow-mode-active.flow-mobile #flowReactRoot {
  flex: 1;
  min-height: 0;
  width: 100%;
}

body.witblox-app.flow-mode-active.flow-mobile .flow-workspace {
  flex: 1;
  min-height: 0;
  width: 100%;
  height: 100%;
}

body.witblox-app.flow-mode-active.flow-mobile .flow-main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

body.witblox-app.flow-mode-active.flow-mobile .flow-react-canvas {
  flex: 1;
  min-width: 0;
  min-height: 0;
  width: 100%;
}

body.witblox-app.flow-mode-active.flow-mobile .flow-sidebar {
  width: clamp(108px, 22vw, 168px);
  flex-shrink: 0;
  padding: 8px 6px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

body.witblox-app.flow-mode-active.flow-mobile .flow-sidebar__head {
  font-size: clamp(9px, 2.4vw, 11px);
  margin-bottom: 6px;
}

body.witblox-app.flow-mode-active.flow-mobile .flow-palette-item {
  padding: 7px 8px;
  margin-bottom: 4px;
  font-size: clamp(9px, 2.5vw, 11px);
  gap: 6px;
}

body.witblox-app.flow-mode-active.flow-mobile .flow-ip-input {
  padding: 7px 8px;
  font-size: clamp(10px, 2.6vw, 12px);
}

body.witblox-app.flow-mode-active.flow-mobile .flow-btn {
  padding: 7px 10px;
  font-size: clamp(10px, 2.6vw, 12px);
}

body.witblox-app.flow-mode-active.flow-mobile .flow-send-oled-btn--sidebar {
  padding: 10px 8px;
  font-size: clamp(10px, 2.6vw, 12px);
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(255, 107, 0, 0.3);
}

body.witblox-app.flow-mode-active.flow-mobile .flow-esp-details {
  font-size: clamp(9px, 2.4vw, 11px);
}

body.witblox-app.flow-mode-active.flow-mobile .flow-esp-detail {
  padding: 4px 0;
}

body.witblox-app.flow-mode-active.flow-mobile .flow-deploy-status {
  flex-shrink: 0;
}

body.witblox-app.flow-mode-active.flow-mobile .react-flow__controls {
  transform: scale(clamp(0.72, 0.14vw + 0.72, 0.9));
  transform-origin: bottom left;
}

body.witblox-app.flow-mode-active.flow-mobile .react-flow__minimap {
  transform: scale(clamp(0.65, 0.12vw + 0.65, 0.85));
  transform-origin: bottom right;
}

/* Short landscape phones (iPhone SE, older iPhones) */
@media (max-height: 430px) and (orientation: landscape) {
  body.witblox-app.flow-mode-active.flow-mobile #header {
    padding-top: max(3px, env(safe-area-inset-top));
    padding-bottom: 3px;
  }

  body.witblox-app.flow-mode-active.flow-mobile .site-title--short {
    font-size: 13px;
  }

  body.witblox-app.flow-mode-active.flow-mobile #modeBar {
    padding-top: 0;
    padding-bottom: 2px;
  }

  body.witblox-app.flow-mode-active.flow-mobile .mode-btn {
    padding: 4px 2px;
    font-size: 10px;
    min-height: 0 !important;
  }

  body.witblox-app.flow-mode-active.flow-mobile .flow-sidebar {
    width: clamp(96px, 20vw, 132px);
    padding: 6px 4px;
  }

  body.witblox-app.flow-mode-active.flow-mobile .flow-palette-item {
    padding: 5px 6px;
    margin-bottom: 3px;
    font-size: 9px;
  }

  body.witblox-app.flow-mode-active.flow-mobile .flow-btn,
  body.witblox-app.flow-mode-active.flow-mobile .flow-ip-input {
    padding: 6px 7px;
    font-size: 10px;
  }
}
