/* LED modal: wider layout and two-column LED grid */
.pf-esp32emu-color-modal-card {
    max-width: 900px;
    width: 86vw;
}
.pf-esp32emu-modal-body {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}
.pf-esp32emu-color-modal-help {
    flex: 0 0 320px;
}
.pf-esp32emu-color-modal-grid.is-led {
    flex: 1 1 auto;
    display: grid !important;
    grid-template-columns: repeat(2, minmax(140px, 1fr));
    gap: 12px;
    align-content: start;
    max-height: 64vh;
    overflow: auto;
    padding-right: 6px;
}
.pf-esp32emu-color-modal-grid.is-led .pf-esp32emu-choice-btn-led {
    width: 100%;
    box-sizing: border-box;
}
.pf-esp32emu-choice-btn-led {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    justify-content: flex-start;
}
.pf-esp32emu-choice-preview svg {
    width: 46px;
    height: auto;
    display: block;
}

/* Enforce per-component preview sizes (override inline SVG attributes) */
.pf-esp32emu-choice-btn-led .pf-esp32emu-choice-preview svg { width: 72px !important; height: auto !important; }
.pf-esp32emu-choice-btn-resistor .pf-esp32emu-choice-preview svg { width: 96px !important; height: auto !important; }
.pf-esp32emu-choice-btn-cap .pf-esp32emu-choice-preview svg { width: 34px !important; height: auto !important; }
.pf-esp32emu-choice-btn-can .pf-esp32emu-choice-preview svg { width: 84px !important; height: auto !important; }

/* Fallback: ensure SVG respects container sizing */
.pf-esp32emu-choice-preview svg { max-width: 100% !important; height: auto !important; display: block; }

/* size modifiers for choice buttons */
.pf-esp32emu-choice-btn-large .pf-esp32emu-choice-preview svg { width: 72px; }
.pf-esp32emu-choice-btn-small .pf-esp32emu-choice-preview svg { width: 40px; }
.pf-esp32emu-choice-btn-large { padding: 14px; }
.pf-esp32emu-choice-btn-small { padding: 8px; }

@media (max-width: 880px) {
    .pf-esp32emu-color-modal-card { width: 94vw; max-width: 720px; }
    .pf-esp32emu-color-modal-help { flex: 0 0 260px; }
    .pf-esp32emu-color-modal-grid.is-led { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
    .pf-esp32emu-color-modal-help { display: none; }
    .pf-esp32emu-color-modal-card { width: 98vw; }
    .pf-esp32emu-color-modal-grid.is-led { grid-template-columns: 1fr; }
}
.pf-esp32emu-choice-btn-led {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
}
.pf-esp32emu-choice-preview { flex: 0 0 96px; display: block; }
.pf-esp32emu-choice-label { font-weight:600 }
:root {
    --pf-esp32emu-bg: #f4f6f9;
    --pf-esp32emu-panel: #ffffff;
    --pf-esp32emu-panel-soft: #eef2f7;
    --pf-esp32emu-border: #d7deea;
    --pf-esp32emu-text: #223042;
    --pf-esp32emu-muted: #667892;
    --pf-esp32emu-accent: #d84b3e;
    --pf-esp32emu-accent-strong: #bf3529;
    --pf-esp32emu-accent-soft: #ffe7e3;
    --pf-esp32emu-cyan: #2d8aa6;
    --pf-esp32emu-shadow: 0 8px 22px rgba(26, 45, 72, 0.12);
    --pf-esp32emu-radius: 14px;
}

#pf-esp32emu-app.pf-esp32emu-box {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-height: 100%;
    color: var(--pf-esp32emu-text);
}

.pf-esp32emu-layout-wrapper.pf-esp32emu-dashboard-shell {
    width: 100vw;
    max-width: none;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
    padding-left: 12px;
    padding-right: 12px;
    box-sizing: border-box;
}

.pf-esp32emu-layout-wrapper.pf-esp32emu-dashboard-shell #pf-esp32emu-app.pf-esp32emu-box {
    width: 100%;
}

#pf-overlay:has(.pf-esp32emu-layout-wrapper.pf-esp32emu-overlay) {
    padding: 8px;
}

#pf-overlay:has(.pf-esp32emu-layout-wrapper.pf-esp32emu-overlay) > #pf-overlay-inner,
#pf-overlay:has(.pf-esp32emu-layout-wrapper.pf-esp32emu-overlay) > .pf-overlay-inner,
#pf-overlay-inner:has(.pf-esp32emu-layout-wrapper.pf-esp32emu-overlay),
.pf-overlay-inner:has(.pf-esp32emu-layout-wrapper.pf-esp32emu-overlay) {
    --pf-overlay-shell-max-width: 100vw;
    max-width: 100%;
}

.pf-esp32emu-launch-context {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    padding: 10px 16px;
    background: rgba(45, 138, 166, 0.12);
    border-bottom: 1px solid rgba(45, 138, 166, 0.2);
    color: var(--pf-esp32emu-text);
    font-size: 0.76rem;
}

.pf-esp32emu-launch-context strong,
.pf-esp32emu-launch-context span {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.68);
    border: 1px solid rgba(45, 138, 166, 0.16);
}

#pf-esp32emu-app .pf-esp32emu-module {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-height: 100%;
}

.pf-esp32emu-header {
    position: sticky;
    top: 0;
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 68px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--pf-esp32emu-border);
    background: color-mix(in srgb, var(--pf-esp32emu-panel) 92%, #ffffff 8%);
    backdrop-filter: blur(7px);
    box-shadow: 0 2px 14px rgba(23, 42, 66, 0.08);
    transition: opacity 0.2s ease, max-height 0.2s ease, padding 0.2s ease;
}

.pf-esp32emu-header-left,
.pf-esp32emu-header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.pf-esp32emu-header-right {
    margin-left: auto;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.pf-esp32emu-header-compact-logo {
    display: none;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: 1px solid var(--pf-esp32emu-border);
    border-radius: 999px;
    background: var(--pf-esp32emu-panel);
    cursor: pointer;
}

.pf-esp32emu-header-compact-logo-image {
    display: block;
}

.pf-esp32emu-drag-handle {
    width: 16px;
    height: 16px;
    border-radius: 5px;
    background:
        radial-gradient(circle at 35% 35%, #ffffff 0 18%, transparent 19%),
        linear-gradient(135deg, var(--pf-esp32emu-accent), var(--pf-esp32emu-cyan));
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.5);
}

.pf-esp32emu-icon-wrapper {
    position: relative;
    width: 40px;
    height: 40px;
    border: 1px solid var(--pf-esp32emu-border);
    border-radius: 11px;
    background: var(--pf-esp32emu-panel);
    overflow: hidden;
}

.pf-esp32emu-tooltip-anchor {
    position: relative;
    overflow: visible;
}

.pf-esp32emu-tooltip-anchor::after {
    content: attr(data-pf-tooltip);
    position: absolute;
    z-index: 1200;
    left: 50%;
    top: calc(100% + 10px);
    transform: translateX(-50%) translateY(-4px);
    width: min(180px, 70vw);
    max-width: min(180px, 70vw);
    padding: 7px 10px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(20, 26, 34, 0.96);
    color: #fff;
    font-size: 0.72rem;
    line-height: 1.28;
    white-space: normal;
    overflow-wrap: anywhere;
    hyphens: auto;
    text-transform: none;
    letter-spacing: 0;
    text-align: left;
    box-shadow: 0 10px 22px rgba(10, 14, 20, 0.24);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.14s ease, transform 0.14s ease;
}

.pf-esp32emu-tooltip-anchor::before {
    content: '';
    position: absolute;
    z-index: 1200;
    left: 50%;
    top: calc(100% + 3px);
    transform: translateX(-50%) translateY(-4px);
    border: 6px solid transparent;
    border-bottom-color: rgba(20, 26, 34, 0.96);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.14s ease, transform 0.14s ease;
}

.pf-esp32emu-tooltip-anchor:hover::after,
.pf-esp32emu-tooltip-anchor:focus-visible::after,
.pf-esp32emu-tooltip-anchor:hover::before,
.pf-esp32emu-tooltip-anchor:focus-visible::before {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.pf-esp32emu-theme-switch [hidden],
.pf-esp32emu-footer-fx-toggle [hidden] {
    display: none !important;
}

.pf-esp32emu-icon-wrapper .pf-esp32emu-icon {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.pf-esp32emu-icon-wrapper .pf-esp32emu-icon[hidden] {
    display: grid !important;
    opacity: 0;
    transform: scale(0.72);
    pointer-events: none;
}

.pf-esp32emu-icon-wrapper .pf-esp32emu-icon:not([hidden]) {
    opacity: 1;
    transform: scale(1);
}

.pf-esp32emu-icon {
    width: 24px;
    height: 24px;
    display: inline-flex;
}

.pf-esp32emu-icon svg,
.pf-esp32emu-theme-icon svg {
    width: 100%;
    height: 100%;
}

/* Temporary wire visual while wiring (follows cursor) */
.pf-temp-wire {
    pointer-events: none;
    stroke-linecap: round;
    stroke-opacity: 0.95;
    transition: stroke-opacity 0.06s linear;
}

/* When near a pin while wiring, show a snap cursor on the main board */
.pf-esp32emu-snap-cursor .pf-esp32emu-workspace-stage,
.pf-esp32emu-snap-cursor .pf-esp32emu-board {
    cursor: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28'%3E%3Ccircle cx='14' cy='14' r='7' fill='%23bf3529' stroke='%23ffffff' stroke-width='2'/%3E%3C/svg%3E") 14 14, pointer !important;
}

.pf-esp32emu-title {
    margin: 0;
    font-size: 1.05rem;
    line-height: 1.2;
}

.pf-esp32emu-meta {
    font-size: 0.78rem;
    color: var(--pf-esp32emu-muted);
}

.pf-esp32emu-controls {
    display: flex;
    gap: 7px;
    flex-wrap: wrap;
}

.pf-esp32emu-btn-iconized {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    line-height: 1;
}

.pf-esp32emu-btn-icon {
    width: 16px;
    height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.pf-esp32emu-btn-icon svg {
    width: 100%;
    height: 100%;
}

.pf-esp32emu-btn {
    border: 1px solid var(--pf-esp32emu-border);
    background: var(--pf-esp32emu-panel);
    color: var(--pf-esp32emu-text);
    border-radius: 9px;
    font-size: 0.82rem;
    font-weight: 600;
    padding: 7px 10px;
    cursor: pointer;
    transition: 0.18s ease;
}

.pf-esp32emu-btn:hover {
    border-color: var(--pf-esp32emu-accent);
    color: var(--pf-esp32emu-accent-strong);
    background: #fff8f7;
}

.pf-esp32emu-btn-primary,
.pf-esp32emu-btn.is-active {
    color: #fff;
    border-color: var(--pf-esp32emu-accent);
    background: linear-gradient(145deg, var(--pf-esp32emu-accent), var(--pf-esp32emu-accent-strong));
}

.pf-esp32emu-btn.is-disabled {
    opacity: 0.56;
    cursor: not-allowed;
    filter: saturate(0.7);
}

.pf-esp32emu-theme-switch {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 34px;
    padding: 0;
    border-radius: 999px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.94) 0%, rgba(241, 246, 252, 0.84) 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 6px 14px rgba(18, 32, 52, 0.08);
}

.pf-esp32emu-btn-icon[hidden] {
    display: none !important;
}

.pf-esp32emu-theme-switch:hover {
    background: linear-gradient(135deg, rgba(255, 255, 255, 1) 0%, rgba(235, 242, 250, 0.92) 100%);
}

#pf-esp32emu-app.is-dark-theme .pf-esp32emu-theme-switch,
#pf-esp32emu-app.pf-esp32emu-app.overlay-mode.is-dark-theme .pf-esp32emu-theme-switch {
    border-color: rgba(255, 255, 255, 0.18);
    background: linear-gradient(135deg, rgba(26, 32, 43, 0.96) 0%, rgba(44, 54, 68, 0.94) 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 6px 14px rgba(0, 0, 0, 0.28);
}

#pf-esp32emu-app.is-dark-theme .pf-esp32emu-theme-switch:hover,
#pf-esp32emu-app.pf-esp32emu-app.overlay-mode.is-dark-theme .pf-esp32emu-theme-switch:hover {
    background: linear-gradient(135deg, rgba(34, 42, 54, 0.98) 0%, rgba(52, 64, 80, 0.96) 100%);
}

.pf-esp32emu-theme-icon {
    width: 16px;
    height: 16px;
    display: inline-flex;
}

.pf-esp32emu-user-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px 4px 5px;
    border-radius: 999px;
    border: 1px solid var(--pf-esp32emu-border);
    background: var(--pf-esp32emu-panel);
    cursor: pointer;
}

.pf-esp32emu-user-avatar {
    width: 27px;
    height: 27px;
    border-radius: 50%;
    overflow: hidden;
    position: relative;
    background: #dce4f0;
}

.pf-esp32emu-avatar-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.pf-esp32emu-avatar-fallback {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-size: 0.72rem;
    font-weight: 700;
    color: #2f3f54;
    background: #dce4f0;
}

.pf-esp32emu-avatar-image[src] + .pf-esp32emu-avatar-fallback {
    display: none;
}

.pf-esp32emu-user-name {
    font-size: 0.76rem;
    color: var(--pf-esp32emu-muted);
    white-space: nowrap;
}

.pf-esp32emu-dashboard-menu {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.pf-esp32emu-btn-dashboard {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 34px;
    padding: 6px 10px;
    border-radius: 999px;
    color: rgba(255, 255, 255, 0.93);
    background: rgba(8, 17, 31, 0.28);
    border: 1px solid rgba(255, 255, 255, 0.22);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14);
    backdrop-filter: blur(8px) saturate(130%);
    -webkit-backdrop-filter: blur(8px) saturate(130%);
    transition: background 0.22s ease, border-color 0.22s ease, box-shadow 0.22s ease;
}

.pf-esp32emu-btn-dashboard:hover,
.pf-esp32emu-btn-dashboard:focus-visible {
    background: rgba(8, 17, 31, 0.42);
    border-color: rgba(255, 255, 255, 0.34);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.pf-esp32emu-dashboard-menu.is-open .pf-esp32emu-btn-dashboard {
    background: rgba(8, 17, 31, 0.42);
    border-color: rgba(255, 179, 0, 0.48);
    box-shadow: 0 0 0 2px rgba(255, 179, 0, 0.32), 0 4px 14px rgba(8, 17, 31, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.14);
}

.pf-esp32emu-dashboard-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    overflow: visible;
}

.pf-esp32emu-dashboard-logo {
    display: block;
    width: 18px;
    height: 18px;
    object-fit: contain;
    transform: scale(1);
    transform-origin: center;
    filter: drop-shadow(0 1px 2px rgba(8, 17, 31, 0.22));
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.25s ease;
}

.pf-esp32emu-btn-dashboard:hover .pf-esp32emu-dashboard-logo,
.pf-esp32emu-btn-dashboard:focus-visible .pf-esp32emu-dashboard-logo {
    transform: scale(1.25) rotate(18deg);
    filter: drop-shadow(0 2px 6px rgba(255, 179, 0, 0.55));
}

.pf-esp32emu-dashboard-submenu {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    min-width: 210px;
    padding: 6px;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.34);
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 14px 30px rgba(8, 17, 31, 0.24);
    display: grid;
    gap: 6px;
    z-index: 120;
}

.pf-esp32emu-dashboard-submenu::before,
.pf-esp32emu-dashboard-submenu::after {
    content: '';
    position: absolute;
    right: 18px;
    width: 0;
    height: 0;
    pointer-events: none;
}

.pf-esp32emu-dashboard-submenu::before {
    top: -9px;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 9px solid rgba(148, 163, 184, 0.34);
}

.pf-esp32emu-dashboard-submenu::after {
    top: -8px;
    border-left: 7px solid transparent;
    border-right: 7px solid transparent;
    border-bottom: 8px solid rgba(255, 255, 255, 0.98);
}

.pf-esp32emu-dashboard-submenu[hidden] {
    display: none !important;
}

.pf-esp32emu-dashboard-submenu-item {
    width: 100%;
    border: 1px solid transparent;
    border-radius: 9px;
    background: transparent;
    color: #0f172a;
    font-size: 0.78rem;
    font-weight: 700;
    line-height: 1.2;
    padding: 9px 11px;
    text-align: left;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}

.pf-esp32emu-dashboard-submenu-item--icon {
    display: flex;
    align-items: center;
    gap: 10px;
}

.pf-esp32emu-dashboard-submenu-item-icon {
    width: 1.15rem;
    height: 1.15rem;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--pf-esp32emu-muted);
}

/* Pin snap highlight when temp-wire is near */
.pf-esp32emu-pin.is-snap-target,
.pf-esp32emu-pin-secondary.is-snap-target {
    box-shadow: 0 0 0 6px rgba(191,53,41,0.22), 0 0 0 2px rgba(255,255,255,0.14) inset, 0 8px 22px rgba(191,53,41,0.22);
    transform: scale(1.14);
    transition: transform 0.05s ease, box-shadow 0.12s ease;
    z-index: 60;
    border-radius: 999px;
    background-clip: padding-box;
}

.pf-esp32emu-pin.is-snap-target::after,
.pf-esp32emu-pin-secondary.is-snap-target::after {
    content: '';
    position: absolute;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    box-shadow: 0 0 0 3px rgba(191,53,41,0.26) inset;
}

.pf-esp32emu-dashboard-submenu-item-icon svg {
    width: 100%;
    height: 100%;
}

.pf-esp32emu-dashboard-submenu-item:hover {
    border-color: rgba(255, 179, 0, 0.28);
    background: linear-gradient(135deg, rgba(255, 122, 61, 0.16) 0%, rgba(255, 179, 0, 0.24) 100%);
    color: #9a3412;
}

.pf-esp32emu-dashboard-submenu-item:focus-visible {
    border-color: rgba(255, 179, 0, 0.44);
    background: linear-gradient(135deg, rgba(255, 122, 61, 0.2) 0%, rgba(255, 179, 0, 0.28) 100%);
    color: #9a3412;
    outline: none;
}

.pf-esp32emu-dashboard-submenu-item--return {
    border-radius: 999px;
    border-color: rgba(148, 163, 184, 0.3);
    background: rgba(248, 250, 252, 0.9);
}

.pf-esp32emu-dashboard-submenu-switch {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border-color: rgba(148, 163, 184, 0.26);
    background: rgba(248, 250, 252, 0.72);
}

.pf-esp32emu-dashboard-submenu-switch-label {
    flex: 1;
}

.pf-esp32emu-dashboard-submenu-switch-ui {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.pf-esp32emu-dashboard-submenu-switch-track {
    width: 34px;
    height: 18px;
    border-radius: 999px;
    border: 1px solid rgba(15, 23, 42, 0.2);
    background: rgba(148, 163, 184, 0.28);
    display: inline-flex;
    align-items: center;
    padding: 2px;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.pf-esp32emu-dashboard-submenu-switch-dot {
    width: 12px;
    height: 12px;
    border-radius: 999px;
    background: #fff;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.25);
    transform: translateX(0);
    transition: transform 0.22s ease;
}

.pf-esp32emu-dashboard-submenu-switch[aria-checked="true"] .pf-esp32emu-dashboard-submenu-switch-track {
    background: rgba(16, 185, 129, 0.28);
    border-color: rgba(5, 150, 105, 0.5);
}

.pf-esp32emu-dashboard-submenu-switch[aria-checked="true"] .pf-esp32emu-dashboard-submenu-switch-dot {
    transform: translateX(16px);
}

#pf-esp32emu-app.is-footer-fx-off .pf-esp32emu-dashboard-submenu-switch-state {
    color: #9f1239;
    background: rgba(244, 63, 94, 0.18);
}

#pf-esp32emu-app.is-footer-fx-off .pf-esp32emu-dashboard-submenu-switch-track {
    background: rgba(244, 63, 94, 0.16);
    border-color: rgba(190, 24, 93, 0.48);
}

#pf-esp32emu-app.is-footer-fx-off .pf-esp32emu-dashboard-submenu-switch-dot {
    transform: translateX(0);
}

.pf-esp32emu-body {
    flex: 1;
    overflow: auto;
    min-height: 0;
    padding: 12px;
    scroll-behavior: smooth;
    background:
        radial-gradient(circle at 7% 0%, rgba(216, 75, 62, 0.12), transparent 34%),
        radial-gradient(circle at 88% 10%, rgba(45, 138, 166, 0.12), transparent 32%),
        linear-gradient(180deg, #f8fafd 0%, var(--pf-esp32emu-bg) 100%);
}

.pf-esp32emu-body::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

.pf-esp32emu-body::-webkit-scrollbar-track {
    background: #e6ebf3;
    border-radius: 999px;
}

.pf-esp32emu-body::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--pf-esp32emu-accent), var(--pf-esp32emu-cyan));
    border-radius: 999px;
    border: 2px solid #e6ebf3;
}

.pf-esp32emu-workspace,
.pf-esp32emu-console,
.pf-esp32emu-template-doc-text,
.pf-esp32emu-sidebar,
.pf-esp32emu-monitor-panel {
    scrollbar-width: thin;
    scrollbar-color: #9aaac2 #e6ebf3;
}

.pf-esp32emu-workspace::-webkit-scrollbar,
.pf-esp32emu-console::-webkit-scrollbar,
.pf-esp32emu-template-doc-text::-webkit-scrollbar,
.pf-esp32emu-sidebar::-webkit-scrollbar,
.pf-esp32emu-monitor-panel::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.pf-esp32emu-workspace::-webkit-scrollbar-track,
.pf-esp32emu-console::-webkit-scrollbar-track,
.pf-esp32emu-template-doc-text::-webkit-scrollbar-track,
.pf-esp32emu-sidebar::-webkit-scrollbar-track,
.pf-esp32emu-monitor-panel::-webkit-scrollbar-track {
    background: #e6ebf3;
    border-radius: 999px;
}

.pf-esp32emu-workspace::-webkit-scrollbar-thumb,
.pf-esp32emu-console::-webkit-scrollbar-thumb,
.pf-esp32emu-template-doc-text::-webkit-scrollbar-thumb,
.pf-esp32emu-sidebar::-webkit-scrollbar-thumb,
.pf-esp32emu-monitor-panel::-webkit-scrollbar-thumb {
    background: #9aaac2;
    border-radius: 999px;
    border: 2px solid #e6ebf3;
}

.pf-esp32emu-info-section,
.pf-esp32emu-layout,
.pf-esp32emu-templates,
.pf-esp32emu-footer {
    border-radius: var(--pf-esp32emu-radius);
    border: 1px solid var(--pf-esp32emu-border);
    background: var(--pf-esp32emu-panel);
}

.pf-esp32emu-info-section {
    margin-bottom: 12px;
    padding: 14px;
}

.pf-esp32emu-board-hint-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 8px;
}

.pf-esp32emu-board-hint-list li {
    list-style: none;
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    line-height: 1.35;
    color: var(--pf-esp32emu-text);
}

.pf-esp32emu-board-hint-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: var(--pf-esp32emu-accent);
    filter: drop-shadow(0 2px 4px rgba(216, 75, 62, 0.16));
}

.pf-esp32emu-info-layout {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 14px;
}

#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-board-hint-list li {
    color: #dbe7f4;
}

.pf-esp32emu-info-block {
    padding: 9px;
    border-radius: 10px;
    background: var(--pf-esp32emu-panel-soft);
    border: 1px solid #dce5f2;
    margin-bottom: 8px;
}

.pf-esp32emu-info-block span {
    display: block;
    font-size: 0.72rem;
    color: var(--pf-esp32emu-muted);
}

.pf-esp32emu-layout {
    --pf-esp32emu-sidebar-width: 250px;
    --pf-esp32emu-monitor-width: 290px;
    display: grid;
    grid-template-columns: var(--pf-esp32emu-sidebar-width) 1fr var(--pf-esp32emu-monitor-width);
    gap: 10px;
    min-height: 580px;
    padding: 10px;
    align-items: start;
    transition: grid-template-columns 0.18s ease, gap 0.18s ease;
}

.pf-esp32emu-sidebar,
.pf-esp32emu-monitor-panel {
    border-radius: 12px;
    border: 1px solid var(--pf-esp32emu-border);
    background: var(--pf-esp32emu-panel-soft);
    padding: 11px;
    overflow-y: auto;
    overflow-x: hidden;
    transition: opacity 0.18s ease, transform 0.18s ease, width 0.18s ease, padding 0.18s ease, border 0.18s ease;
    min-width: 0;
}

.pf-esp32emu-monitor-panel {
    align-self: start;
    position: sticky;
    top: 12px;
    max-height: calc(100vh - 24px);
}

.pf-esp32emu-monitor-resizer {
    position: absolute;
    left: -8px;
    top: 8px;
    bottom: 8px;
    width: 12px;
    border-radius: 8px;
    cursor: col-resize;
    background: linear-gradient(180deg, rgba(74, 124, 171, 0.14), rgba(74, 124, 171, 0.04));
    border: 1px solid rgba(74, 124, 171, 0.28);
    opacity: 0.44;
    transition: opacity 0.16s ease, background 0.16s ease;
    z-index: 3;
}

.pf-esp32emu-monitor-resizer:hover,
.pf-esp32emu-monitor-resizer:focus-visible {
    opacity: 0.92;
    background: linear-gradient(180deg, rgba(74, 124, 171, 0.28), rgba(74, 124, 171, 0.12));
}

.pf-esp32emu-monitor-panel.is-panel-hidden .pf-esp32emu-monitor-resizer {
    display: none;
}

.pf-esp32emu-section-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.74rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--pf-esp32emu-muted);
    margin-bottom: 8px;
    font-weight: 700;
}

.pf-esp32emu-inline-info {
    width: 17px;
    height: 17px;
    border-radius: 50%;
    border: 1px solid #b4c2d6;
    background: #f2f7ff;
    color: #365377;
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: help;
    padding: 0;
}

.pf-esp32emu-board-tools {
    display: grid;
    gap: 8px;
    margin-bottom: 12px;
}

.pf-esp32emu-wire-color-status {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 10px;
    margin-bottom: 14px;
    border: 1px solid var(--pf-esp32emu-border);
    border-radius: 10px;
    background: #fff;
    cursor: pointer;
    width: 100%;
    text-align: left;
    transition: background 0.12s ease, border-color 0.12s ease;
}

.pf-esp32emu-wire-color-status:hover {
    background: var(--pf-esp32emu-panel-soft, #f4f6f9);
    border-color: var(--pf-esp32emu-accent, #3498db);
}

.pf-esp32emu-wire-color-status:focus-visible {
    outline: 2px solid var(--pf-esp32emu-accent, #3498db);
    outline-offset: 2px;
}

.pf-esp32emu-wire-color-label {
    font-size: 0.8rem;
    color: var(--pf-esp32emu-muted);
}

.pf-esp32emu-wire-color-chip {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px #bcc8d8;
    background: #2c3e50;
}

.pf-esp32emu-wire-color-chip.is-light {
    box-shadow: 0 0 0 1px #bcc8d8, inset 0 0 0 1px #d7deea;
}

.pf-esp32emu-res-list,
.pf-esp32emu-comp-list {
    display: grid;
    gap: 6px;
    margin-bottom: 12px;
}

.pf-esp32emu-comp-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.pf-esp32emu-res-opt,
.pf-esp32emu-comp-item,
.pf-esp32emu-template-chip {
    border: 1px solid var(--pf-esp32emu-border);
    border-radius: 10px;
    background: #fff;
    color: var(--pf-esp32emu-text);
    cursor: pointer;
    padding: 8px;
    font-size: 0.82rem;
}

.pf-esp32emu-res-opt.is-active,
.pf-esp32emu-res-opt:hover,
.pf-esp32emu-comp-item:hover,
.pf-esp32emu-template-chip:hover {
    border-color: var(--pf-esp32emu-accent);
    background: var(--pf-esp32emu-accent-soft);
}

.pf-esp32emu-template-chip.is-active {
    border-color: var(--pf-esp32emu-accent);
    color: #fff;
    background: linear-gradient(145deg, var(--pf-esp32emu-accent), var(--pf-esp32emu-accent-strong));
}

.pf-esp32emu-comp-item {
    display: grid;
    place-items: center;
    gap: 6px;
}

.pf-esp32emu-comp-item.is-workbench-static {
    opacity: 0.72;
    cursor: default;
    background: linear-gradient(180deg, #f9fbff 0%, #edf3fb 100%);
}

.pf-esp32emu-comp-item.is-workbench-static:hover {
    border-color: var(--pf-esp32emu-border);
    background: linear-gradient(180deg, #f9fbff 0%, #edf3fb 100%);
}

.pf-esp32emu-comp-item .pf-esp32emu-icon {
    width: 22px;
    height: 22px;
    color: var(--pf-esp32emu-accent-strong);
}

/* Sidebar size modifiers for component preview icons */
.pf-esp32emu-comp-item.pf-esp32emu-comp-size-large .pf-esp32emu-icon { width: 36px; height: 36px; }
.pf-esp32emu-comp-item.pf-esp32emu-comp-size-small .pf-esp32emu-icon { width: 18px; height: 18px; }

.pf-esp32emu-comp-label {
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.pf-esp32emu-workspace {
    min-height: 560px;
    min-width: 0;
    border-radius: 12px;
    border: 1px solid var(--pf-esp32emu-border);
    background: linear-gradient(145deg, #e2edf8 0%, #d4e4f5 55%, #d9ecfb 100%);
    overflow-x: auto;
    overflow-y: auto;
    scrollbar-gutter: stable both-edges;
    position: relative;
}

.pf-esp32emu-workspace-stage {
    position: relative;
    width: calc(100% - 36px);
    min-width: 900px;
    height: 860px;
    border-radius: 18px;
    margin: 18px;
    overflow: hidden;
    background:
        radial-gradient(140% 110% at 80% 85%, rgba(255, 255, 255, 0.16) 0%, rgba(255, 255, 255, 0) 62%),
        radial-gradient(105% 80% at 15% 10%, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0) 56%),
        linear-gradient(165deg, #2f8ac0 0%, #2389c4 43%, #1a81bb 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), inset 0 -22px 48px rgba(0, 0, 0, 0.08);
    transform-origin: top left;
    z-index: 2;
    cursor: grab;
    touch-action: none;
}

.pf-esp32emu-workspace-stage.is-panning {
    cursor: grabbing;
}

.pf-esp32emu-workspace-world {
    position: absolute;
    inset: 0;
    transform-origin: top left;
}

.pf-esp32emu-arbeitsmatte-texture {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    background:
        radial-gradient(circle at 35% 35%, rgba(255, 255, 255, 0.07) 0%, rgba(255, 255, 255, 0) 50%),
        radial-gradient(circle at 70% 60%, rgba(0, 0, 0, 0.06) 0%, rgba(0, 0, 0, 0) 56%);
}

.pf-esp32emu-arbeitsmatte-texture::after {
    content: "";
    position: absolute;
    left: 1084px;
    top: 789px;
    width: 105px;
    height: 105px;
    background: url("../img/pf_logo.svg") center/contain no-repeat;
    opacity: 0.18;
    filter: drop-shadow(0 1px 2px rgba(255, 255, 255, 0.16));
}

.pf-esp32emu-arbeitsmatte-grid {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    opacity: 0;
    transition: opacity 0.22s ease;
    background-image:
        linear-gradient(to right, rgba(255, 255, 255, 0.19) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(255, 255, 255, 0.19) 1px, transparent 1px),
        linear-gradient(to right, rgba(255, 255, 255, 0.28) 2px, transparent 2px),
        linear-gradient(to bottom, rgba(255, 255, 255, 0.28) 2px, transparent 2px);
    background-size: 20px 20px, 20px 20px, 100px 100px, 100px 100px;
}

#pf-esp32emu-app.is-arbeitsmatte-grid .pf-esp32emu-arbeitsmatte-grid {
    opacity: 0.88;
}

.pf-esp32emu-workbench-zone {
    position: absolute;
    width: 340px;
    height: 123px;
    min-width: 140px;
    border-radius: 14px;
    border: 1px dashed rgba(255, 255, 255, 0.42);
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.86);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    display: grid;
    align-content: start;
    text-align: center;
    padding: 10px 12px;
    box-sizing: border-box;
    z-index: 3;
    user-select: none;
    gap: 8px;
}

.pf-esp32emu-workbench-zone-title {
    font-size: 0.72rem;
    letter-spacing: 0.09em;
    opacity: 0.92;
}

.pf-esp32emu-workbench-zone-slots {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.pf-esp32emu-workbench-zone-signal-generator .pf-esp32emu-workbench-zone-slots {
    grid-template-columns: minmax(0, 1fr);
}

.pf-esp32emu-workbench-device-slot {
    border: 1px dashed rgba(255, 255, 255, 0.24);
    border-radius: 10px;
    min-height: 72px;
    background: rgba(255, 255, 255, 0.035);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03);
    display: grid;
    place-items: center;
    gap: 4px;
    padding: 6px 6px 7px;
}

.pf-esp32emu-workbench-device-label {
    font-size: 0.6rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    opacity: 0.66;
}

.pf-esp32emu-workbench-device-silhouette {
    display: inline-block;
    border: 1px solid rgba(255, 255, 255, 0.22);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02));
    box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.05);
    opacity: 0.56;
}

.pf-esp32emu-workbench-device-silhouette[data-pf-esp32emu-device-silhouette="psu"],
.pf-esp32emu-workbench-device-silhouette[data-pf-esp32emu-device-silhouette="strong-psu"] {
    width: 48px;
    height: 30px;
    border-radius: 5px;
}

.pf-esp32emu-workbench-device-silhouette[data-pf-esp32emu-device-silhouette="voltmeter"],
.pf-esp32emu-workbench-device-silhouette[data-pf-esp32emu-device-silhouette="oscope"],
.pf-esp32emu-workbench-device-silhouette[data-pf-esp32emu-device-silhouette="signal-generator"] {
    width: 56px;
    height: 34px;
    border-radius: 7px;
}

/* PSU short-circuit LED indicator */
.pf-esp32emu-workbench-device-silhouette [data-role="psu-led"] {
    transition: fill 140ms ease, filter 140ms ease, opacity 140ms ease;
    fill: #3a3a3a;
    opacity: 0.95;
}
.pf-esp32emu-workbench-device-silhouette [data-role="psu-led"].is-short {
    fill: #ff3030;
    filter: drop-shadow(0 0 6px rgba(255,48,48,0.9));
}

/* Broader rule: ensure LED shows and can blink even when SVG is placed outside workbench silhouette wrapper */
[data-role="psu-led"] {
    transition: fill 140ms ease, filter 140ms ease, opacity 140ms ease, transform 140ms ease;
    fill: #3a3a3a;
    opacity: 0.95;
}

[data-role="psu-led"].is-short {
    fill: #ff3030 !important;
    filter: drop-shadow(0 0 8px rgba(255,48,48,0.95)) !important;
    animation: pf-esp32emu-psu-blink 900ms linear infinite;
    transform-origin: center center;
}

@keyframes pf-esp32emu-psu-blink {
    0% { opacity: 1; transform: scale(1); }
    45% { opacity: 0.35; transform: scale(0.84); }
    100% { opacity: 1; transform: scale(1); }
}

.pf-esp32emu-workbench-device-slot.is-drop-target {
    border-style: solid;
    border-color: rgba(46, 204, 113, 0.92);
    background: rgba(46, 204, 113, 0.16);
}

.pf-esp32emu-workbench-device-slot.is-drop-blocked {
    border-style: solid;
    border-color: rgba(255, 107, 107, 0.95);
    background: rgba(255, 107, 107, 0.14);
}

.pf-esp32emu-workbench-zone-power {
    left: 12px;
    top: 12px;
}

.pf-esp32emu-workbench-zone-signal-generator {
    left: 50%;
    top: 12px;
    transform: translateX(-50%);
}

.pf-esp32emu-workbench-zone-measure {
    right: 12px;
    top: 12px;
}

.pf-esp32emu-board-ghost-layer {
    position: absolute;
    inset: 0;
    z-index: 4;
    pointer-events: none;
}

.pf-esp32emu-board-ghost {
    position: absolute;
    width: 240px;
    height: 88px;
    border-radius: 10px;
    border: 1px dashed rgba(255, 255, 255, 0.72);
    background: rgba(255, 255, 255, 0.18);
    color: rgba(255, 255, 255, 0.95);
    box-shadow: 0 10px 24px rgba(13, 47, 76, 0.2);
    backdrop-filter: blur(1.5px);
    display: grid;
    place-items: center;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    transform-origin: center center;
    pointer-events: auto;
    cursor: pointer;
}

.pf-esp32emu-board-ghost.is-active {
    border-style: solid;
    border-color: #ffffff;
    background: rgba(255, 255, 255, 0.28);
}

.pf-esp32emu-workspace-controls {
    margin: 0 0 12px 40px;
    padding: 0 10px;
    width: max-content;
    max-width: calc(100% - 50px);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    position: relative;
    z-index: 18;
}

.pf-esp32emu-workspace-control-group {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.pf-esp32emu-workspace-controls .pf-esp32emu-btn {
    min-height: 36px;
}

/* Settings button when placed inside the workspace world (floats top-right)
   Keep above wires (wire svg z-index:20) */
.pf-esp32emu-workspace-world > #pf-esp32emu-btn-settings {
    position: absolute;
    right: 8px;
    top: 8px;
    z-index: 120;
    padding: 6px 8px;
    font-size: 12px;
    border-radius: 6px;
    background: var(--pf-esp32emu-panel);
    border: 1px solid var(--pf-esp32emu-border);
    color: var(--pf-esp32emu-text);
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}
.pf-esp32emu-workspace-world > #pf-esp32emu-btn-settings:hover {
    background: #fff8f7;
    border-color: var(--pf-esp32emu-accent);
}

.pf-esp32emu-breadboard {
    position: absolute;
    display: block;
    --pf-esp32emu-grid-step: 26px;
    --pf-esp32emu-grid-row: 26px;
    --pf-esp32emu-board-label-width: 30px;
    --pf-esp32emu-board-cols: 30;
    left: 320px;
    top: 220px;
    margin: 0;
    width: calc(var(--pf-esp32emu-board-label-width) + (var(--pf-esp32emu-board-cols) * var(--pf-esp32emu-grid-step)) + 30px);
    min-width: calc(var(--pf-esp32emu-board-label-width) + (var(--pf-esp32emu-board-cols) * var(--pf-esp32emu-grid-step)) + 30px);
    z-index: 2;
    transform-origin: top left;
    z-index: 6;
}

#pf-esp32emu-app.is-workspace-focus .pf-esp32emu-layout {
    grid-template-columns: var(--pf-esp32emu-sidebar-width) 1fr var(--pf-esp32emu-monitor-width);
}

#pf-esp32emu-app.is-workspace-focus .pf-esp32emu-template-section,
#pf-esp32emu-app.is-workspace-fullscreen .pf-esp32emu-template-section {
    display: none;
}

#pf-esp32emu-app.is-workspace-fullscreen {
    height: 100vh;
    overflow: hidden;
    background: #eef3fb;
}

#pf-esp32emu-app.is-workspace-fullscreen .pf-esp32emu-module {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#pf-esp32emu-app.is-workspace-fullscreen .pf-esp32emu-layout {
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: stretch;
    gap: 10px;
}

#pf-esp32emu-app.is-workspace-fullscreen .pf-esp32emu-workspace {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#pf-esp32emu-app.is-workspace-fullscreen .pf-esp32emu-workspace-stage {
    flex: 1;
    width: 100%;
    height: auto;
    min-height: 300px;
    margin: 8px;
}

#pf-esp32emu-app.is-workspace-fullscreen .pf-esp32emu-monitor-panel {
    flex: 0 0 min(460px, 34vw);
    max-width: min(460px, 34vw);
    min-width: 320px;
}

#pf-esp32emu-app.is-workspace-fullscreen .pf-esp32emu-workspace-controls {
    flex-shrink: 0;
}

.pf-esp32emu-breadboard-default {
    --pf-esp32emu-board-cols: 30;
}

.pf-esp32emu-breadboard-wide {
    --pf-esp32emu-board-cols: 70;
}

.pf-esp32emu-breadboard-wrapper {
    position: relative;
    padding: 15px;
    background: #fdfdfd;
    border-radius: 6px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    border: 1px solid #eee;
}

.pf-esp32emu-breadboard-signature {
    position: absolute;
    right: 10px;
    bottom: 6px;
    font-size: 0.56rem;
    letter-spacing: 0.03em;
    color: #6f8199;
    opacity: 0.72;
    pointer-events: none;
    z-index: 9;
}

.pf-esp32emu-grid-master {
    display: grid;
    position: relative;
    z-index: 5;
    grid-template-columns: var(--pf-esp32emu-board-label-width) repeat(var(--pf-esp32emu-board-cols), var(--pf-esp32emu-grid-step));
    grid-auto-rows: var(--pf-esp32emu-grid-row);
    gap: 0;
    background: #fff;
    border: 1px solid #eee;
}

.pf-esp32emu-grid-master-secondary {
    margin-top: 12px;
    opacity: 0.97;
    z-index: 4;
    pointer-events: auto;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.pf-esp32emu-grid-void {
    height: 10px;
    background: transparent;
}

.pf-esp32emu-cell-label-row,
.pf-esp32emu-cell-label-pwr,
.pf-esp32emu-cell-number,
.pf-esp32emu-cell-number-spacer {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #7f8c8d;
    background: #fff;
}

.pf-esp32emu-cell-label-row {
    font-family: Consolas, Monaco, monospace;
    font-weight: 700;
    font-size: 14px;
}

.pf-esp32emu-cell-label-pwr {
    font-weight: 700;
    font-size: 16px;
}

.pf-esp32emu-cell-label-pwr.pwr-plus {
    color: #e74c3c;
}

.pf-esp32emu-cell-label-pwr.pwr-minus {
    color: #3498db;
}

.pf-esp32emu-cell-number {
    font-family: Consolas, Monaco, monospace;
    font-size: 11px;
    margin-top: 2px;
}

.pf-esp32emu-cell-hole {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
}

.pf-esp32emu-cell-hole.power-row-bg {
    background: rgba(231, 76, 60, 0.05);
    border-bottom: 1px solid #eee;
}

.pf-esp32emu-cell-hole.power-row-bg.blue {
    background: rgba(52, 152, 219, 0.05);
}

.pf-esp32emu-cell-rift {
    height: 18px;
    background: #f0f0f0;
    border-top: 1px solid #e0e0e0;
    border-bottom: 1px solid #e0e0e0;
}

.pf-esp32emu-pin {
    position: relative;
    width: 10px;
    height: 10px;
    border: 0;
    padding: 0;
    border-radius: 50%;
    background: #cfd8dc;
    box-shadow: inset 1px 1px 2px rgba(0, 0, 0, 0.5);
    cursor: pointer;
    transition: transform 0.1s ease, background-color 0.1s ease, box-shadow 0.1s ease;
    z-index: 25;
}

.pf-esp32emu-pin-ghost {
    display: block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #d5dce2;
    box-shadow: inset 1px 1px 2px rgba(0, 0, 0, 0.34);
    opacity: 0.9;
}

.pf-esp32emu-pin:hover {
    transform: scale(1.3);
    background: #999;
}

.pf-esp32emu-pin.is-active {
    background: #3498db;
    box-shadow: 0 0 5px #3498db;
}

.pf-esp32emu-wire-svg {
    position: absolute;
    top: 15px;
    left: 15px;
    width: calc(100% - 30px);
    height: calc(100% - 30px);
    overflow: visible;
    pointer-events: none;
    z-index: 20;
}

.pf-esp32emu-breadboard-has-secondary .pf-esp32emu-breadboard-signature {
    bottom: 10px;
}

.pf-esp32emu-placed-item {
    position: absolute;
    z-index: 30;
    cursor: grab;
    filter: drop-shadow(0 5px 10px rgba(20, 35, 56, 0.25));
}

.pf-esp32emu-placed-item.is-component-defect {
    opacity: 0.82;
    filter: grayscale(1) saturate(0.16) brightness(0.78) contrast(0.88) drop-shadow(0 8px 18px rgba(60, 48, 32, 0.28));
}

.pf-esp32emu-placed-item.is-component-defect svg,
.pf-esp32emu-placed-item.is-component-defect img {
    filter: grayscale(1) saturate(0.1) brightness(0.82) contrast(0.9);
}

.pf-esp32emu-placed-item.is-component-defect .pf-esp32emu-port {
    background: #9aa0a8;
    box-shadow: 0 0 0 2px #646b73;
}

.pf-esp32emu-placed-item.is-component-defect .pf-esp32emu-port.is-active {
    background: #8b929a;
    box-shadow: 0 0 0 2px #5d646c, 0 0 4px rgba(150, 150, 150, 0.22);
}

.pf-esp32emu-placed-item.is-component-defect .pf-esp32emu-port-label {
    color: #4d535a;
    background: rgba(232, 235, 239, 0.96);
    border-color: #b8c0ca;
}

.pf-esp32emu-placed-item.is-component-defect .pf-esp32emu-esp32-power-led-core {
    border-color: #6d737a;
    background: #868d95;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}

.pf-esp32emu-placed-item.is-component-defect .pf-esp32emu-esp32-power-led-glow {
    opacity: 0;
}

.pf-esp32emu-placed-item.is-component-defect[data-pf-esp32emu-comp-type="resistor"]::before,
.pf-esp32emu-placed-item.is-component-defect[data-pf-esp32emu-comp-type="resistor"]::after,
.pf-esp32emu-placed-item.is-component-defect[data-pf-esp32emu-comp-type="cap"]::before,
.pf-esp32emu-placed-item.is-component-defect[data-pf-esp32emu-comp-type="cap"]::after,
.pf-esp32emu-placed-item.is-component-defect[data-pf-esp32emu-comp-type="led"]::before,
.pf-esp32emu-placed-item.is-component-defect[data-pf-esp32emu-comp-type="led"]::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 110;
}

.pf-esp32emu-placed-item.is-component-defect[data-pf-esp32emu-comp-type="resistor"]::before {
    width: 82%;
    height: 34%;
    top: 50%;
    border-radius: 999px;
    background:
        radial-gradient(circle at 32% 46%, rgba(14, 14, 14, 0.88) 0%, rgba(18, 14, 12, 0.88) 24%, rgba(18, 14, 12, 0) 58%),
        radial-gradient(circle at 68% 54%, rgba(52, 32, 18, 0.58) 0%, rgba(52, 32, 18, 0) 52%),
        linear-gradient(90deg, rgba(18, 12, 8, 0) 0%, rgba(28, 18, 12, 0.84) 14%, rgba(84, 50, 26, 0.78) 48%, rgba(28, 18, 12, 0.84) 86%, rgba(18, 12, 8, 0) 100%);
    box-shadow: 0 0 12px rgba(28, 18, 12, 0.35);
    filter: blur(0.2px);
}

.pf-esp32emu-placed-item.is-component-defect[data-pf-esp32emu-comp-type="resistor"]::after {
    width: 70%;
    height: 10%;
    top: 48%;
    background:
        linear-gradient(100deg, rgba(238, 224, 198, 0) 0%, rgba(238, 224, 198, 0.42) 46%, rgba(70, 52, 36, 0.08) 52%, rgba(238, 224, 198, 0.32) 58%, rgba(238, 224, 198, 0) 100%),
        linear-gradient(90deg, rgba(18, 10, 8, 0.18) 0%, rgba(18, 10, 8, 0.72) 50%, rgba(18, 10, 8, 0.18) 100%);
    border-radius: 999px;
    transform: translate(-50%, -50%) rotate(-9deg);
    opacity: 0.9;
}

.pf-esp32emu-placed-item.is-component-defect[data-pf-esp32emu-comp-type="cap"]::before {
    width: 46%;
    height: 18%;
    top: 16%;
    border-radius: 12px 12px 6px 6px;
    background:
        linear-gradient(90deg, rgba(230, 232, 235, 0.18) 0%, rgba(250, 248, 244, 0.62) 46%, rgba(46, 20, 18, 0.9) 50%, rgba(250, 248, 244, 0.52) 54%, rgba(230, 232, 235, 0.12) 100%),
        linear-gradient(180deg, rgba(40, 44, 50, 0.95) 0%, rgba(88, 34, 28, 0.86) 100%);
    box-shadow: 0 2px 6px rgba(24, 18, 16, 0.28);
}

.pf-esp32emu-placed-item.is-component-defect[data-pf-esp32emu-comp-type="cap"]::after {
    width: 18%;
    height: 46%;
    top: 39%;
    background:
        linear-gradient(180deg, rgba(30, 18, 14, 0.96) 0%, rgba(70, 44, 26, 0.82) 32%, rgba(118, 94, 54, 0.48) 60%, rgba(118, 94, 54, 0) 100%),
        linear-gradient(110deg, rgba(255, 248, 238, 0) 0%, rgba(255, 248, 238, 0.4) 47%, rgba(58, 38, 26, 0.08) 53%, rgba(255, 248, 238, 0.2) 58%, rgba(255, 248, 238, 0) 100%);
    border-radius: 4px 4px 14px 14px;
    transform: translate(-50%, -50%) rotate(7deg);
    opacity: 0.86;
}

.pf-esp32emu-placed-item.is-component-defect[data-pf-esp32emu-comp-type="led"]::before {
    width: 42%;
    height: 42%;
    top: 37%;
    border-radius: 50% 50% 42% 42%;
    background:
        radial-gradient(circle at 50% 56%, rgba(12, 14, 16, 0.88) 0%, rgba(24, 26, 30, 0.84) 28%, rgba(24, 26, 30, 0.14) 58%, rgba(24, 26, 30, 0) 72%),
        linear-gradient(135deg, rgba(228, 232, 238, 0) 0%, rgba(228, 232, 238, 0.44) 47%, rgba(46, 48, 54, 0.12) 50%, rgba(228, 232, 238, 0.36) 53%, rgba(228, 232, 238, 0) 100%),
        linear-gradient(45deg, rgba(228, 232, 238, 0) 0%, rgba(228, 232, 238, 0.26) 49%, rgba(52, 54, 60, 0.16) 51%, rgba(228, 232, 238, 0.12) 54%, rgba(228, 232, 238, 0) 100%);
    box-shadow: inset 0 -2px 6px rgba(8, 10, 12, 0.48), 0 0 8px rgba(18, 18, 18, 0.2);
}

.pf-esp32emu-placed-item.is-component-defect[data-pf-esp32emu-comp-type="led"]::after {
    width: 14%;
    height: 14%;
    top: 45%;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(8, 8, 8, 0.98) 0%, rgba(30, 28, 26, 0.86) 52%, rgba(30, 28, 26, 0) 100%);
    box-shadow: 0 0 10px rgba(10, 10, 10, 0.42);
}

.pf-esp32emu-damage-fx {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 220px;
    height: 220px;
    transform: translate(-50%, -58%);
    pointer-events: none;
    overflow: visible;
    z-index: 120;
}

.pf-esp32emu-damage-fx-flash,
.pf-esp32emu-damage-fx-shockwave,
.pf-esp32emu-damage-fx-spark,
.pf-esp32emu-damage-fx-cloud {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    will-change: transform, opacity;
}

.pf-esp32emu-damage-fx-flash {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: radial-gradient(circle at center, rgba(255, 250, 226, 1) 0%, rgba(255, 195, 94, 0.92) 28%, rgba(255, 108, 38, 0.55) 54%, rgba(255, 108, 38, 0) 78%);
    mix-blend-mode: screen;
}

.pf-esp32emu-damage-fx-shockwave {
    width: 28px;
    height: 28px;
    border: 3px solid rgba(255, 248, 235, 0.95);
    border-radius: 50%;
}

.pf-esp32emu-damage-fx-cloud {
    width: var(--pf-esp32emu-damage-cloud-size, 46px);
    height: var(--pf-esp32emu-damage-cloud-size, 46px);
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, rgba(212, 212, 212, 0.95) 0%, rgba(146, 146, 146, 0.74) 46%, rgba(58, 58, 58, 0) 74%);
    mix-blend-mode: multiply;
    animation-delay: var(--pf-esp32emu-damage-delay, 0s);
}

.pf-esp32emu-damage-fx-spark {
    width: 3px;
    height: 16px;
    border-radius: 999px;
    background: linear-gradient(180deg, rgba(255, 248, 208, 1) 0%, rgba(255, 190, 90, 0.95) 48%, rgba(255, 94, 42, 0.2) 100%);
    box-shadow: 0 0 8px rgba(255, 176, 74, 0.65);
    transform-origin: center 85%;
    animation-delay: var(--pf-esp32emu-damage-spark-delay, 0s);
}

.pf-esp32emu-damage-fx[data-pf-esp32emu-comp-type="resistor"] .pf-esp32emu-damage-fx-cloud {
    filter: saturate(0.7) brightness(0.78);
}

.pf-esp32emu-damage-fx[data-pf-esp32emu-comp-type="cap"] .pf-esp32emu-damage-fx-cloud {
    filter: saturate(1.08) brightness(0.94);
}

.pf-esp32emu-damage-fx[data-pf-esp32emu-comp-type="led"] .pf-esp32emu-damage-fx-cloud {
    filter: saturate(0.84) brightness(0.86);
}

.pf-esp32emu-damage-fx.is-active .pf-esp32emu-damage-fx-flash {
    animation: pf-esp32emu-damage-flash 420ms ease-out forwards;
}

.pf-esp32emu-damage-fx.is-active .pf-esp32emu-damage-fx-shockwave {
    animation: pf-esp32emu-damage-shockwave 650ms ease-out forwards;
}

.pf-esp32emu-damage-fx.is-active .pf-esp32emu-damage-fx-spark {
    animation: pf-esp32emu-damage-spark 520ms ease-out forwards;
}

.pf-esp32emu-damage-fx.is-active .pf-esp32emu-damage-fx-cloud {
    animation: pf-esp32emu-damage-cloud 10.8s cubic-bezier(0.33, 0, 0.18, 1) forwards;
}

@keyframes pf-esp32emu-damage-flash {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.08);
    }
    10% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.45);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(2.2);
    }
}

@keyframes pf-esp32emu-damage-shockwave {
    0% {
        opacity: 0.86;
        transform: translate(-50%, -50%) scale(0.1);
        border-width: 10px;
    }
    55% {
        opacity: 0.34;
        transform: translate(-50%, -50%) scale(1.2);
        border-width: 2px;
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(2.55);
        border-width: 0;
    }
}

@keyframes pf-esp32emu-damage-spark {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.45) rotate(0deg);
    }
    12% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1) rotate(var(--pf-esp32emu-damage-spark-rot, 0deg));
    }
    100% {
        opacity: 0;
        transform: translate(calc(-50% + var(--pf-esp32emu-damage-spark-x, 0px)), calc(-50% + var(--pf-esp32emu-damage-spark-y, -80px))) scale(0.65) rotate(var(--pf-esp32emu-damage-spark-rot, 0deg));
    }
}

@keyframes pf-esp32emu-damage-cloud {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.05) rotate(0deg);
    }
    4% {
        opacity: 1;
        transform: translate(calc(-50% + (var(--pf-esp32emu-damage-move-x, 0px) * 0.15)), calc(-50% + (var(--pf-esp32emu-damage-move-y, -120px) * 0.11))) scale(0.78) rotate(var(--pf-esp32emu-damage-rot-start, 0deg));
    }
    36% {
        opacity: 0.76;
        transform: translate(calc(-50% + (var(--pf-esp32emu-damage-move-x, 0px) * 0.56)), calc(-50% + (var(--pf-esp32emu-damage-move-y, -120px) * 0.52))) scale(1.9) rotate(calc(var(--pf-esp32emu-damage-rot-start, 0deg) * 0.7));
    }
    100% {
        opacity: 0;
        transform: translate(calc(-50% + var(--pf-esp32emu-damage-move-x, 0px)), calc(-50% + var(--pf-esp32emu-damage-move-y, -160px))) scale(3.9) rotate(var(--pf-esp32emu-damage-rot-end, 90deg));
    }
}

.pf-esp32emu-esp32-power-led {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 14px;
    height: 14px;
    pointer-events: none;
    z-index: 3;
}

.pf-esp32emu-esp32-power-led-core {
    position: absolute;
    left: 2px;
    top: 2px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 1px solid #5e6875;
    background: #3a414c;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.pf-esp32emu-esp32-power-led-glow {
    position: absolute;
    left: -3px;
    top: -3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    opacity: 0;
    background: radial-gradient(circle at center, rgba(108, 255, 143, 0.65) 0%, rgba(108, 255, 143, 0.14) 45%, rgba(108, 255, 143, 0) 72%);
    transition: opacity 160ms ease;
}

.pf-esp32emu-placed-item.is-esp32-powered .pf-esp32emu-esp32-power-led-core {
    border-color: #6dc57e;
    background: #79f093;
    box-shadow: 0 0 8px rgba(109, 197, 126, 0.8), inset 0 0 0 1px rgba(255, 255, 255, 0.3);
}

.pf-esp32emu-placed-item.is-esp32-powered .pf-esp32emu-esp32-power-led-glow {
    opacity: 1;
}

.pf-esp32emu-placed-item.pf-esp32emu-placement-blocked {
    outline: 3px solid #e74c3c;
    outline-offset: 2px;
}

.pf-esp32emu-placed-item.pf-esp32emu-placement-blocked::after {
    content: attr(data-pf-esp32emu-blocked-text);
    position: absolute;
    left: 50%;
    bottom: calc(100% + 6px);
    transform: translateX(-50%);
    background: rgba(231, 76, 60, 0.94);
    color: #fff;
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(110, 20, 20, 0.28);
    z-index: 500;
}

.pf-esp32emu-workspace.is-drop-blocked {
    box-shadow: inset 0 0 0 3px rgba(231, 76, 60, 0.35);
}

.pf-esp32emu-component-menu {
    position: absolute;
    z-index: 260;
    display: none;
    min-width: 220px;
    padding: 10px;
    border: 1px solid var(--pf-esp32emu-border);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 16px 34px rgba(23, 42, 66, 0.18);
    backdrop-filter: blur(6px);
    overflow: visible;
}

.pf-esp32emu-component-menu.is-open {
    display: grid;
    gap: 8px;
    overflow: visible;
}

.pf-esp32emu-component-menu-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 0.8rem;
    font-weight: 700;
    color: #51657f;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.pf-esp32emu-component-menu-live {
    display: inline-flex;
    align-items: center;
    padding: 2px 7px;
    border-radius: 999px;
    border: 1px solid #c9d9ed;
    background: #eef5ff;
    color: #2f6fb2;
    font-size: 0.64rem;
    font-weight: 700;
    letter-spacing: 0.08em;
}

.pf-esp32emu-component-menu-btn {
    width: 100%;
    border: 1px solid #d9e2ef;
    border-radius: 9px;
    background: #f7faff;
    color: #1f2d40;
    padding: 8px 10px;
    text-align: left;
    cursor: pointer;
    font-weight: 600;
}

.pf-esp32emu-component-menu-btn:hover {
    border-color: #7f98b8;
    background: #eef4ff;
}

.pf-esp32emu-component-menu-btn.is-danger {
    color: #b03a2e;
}

.pf-esp32emu-component-menu-status {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px 10px;
    border-radius: 8px;
    background: #f0f5ff;
    border: 1px solid #d4e2f7;
}

.pf-esp32emu-cstatus-row {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.4;
}

.pf-esp32emu-cstatus-row.is-ok     { color: #217a3c; }
.pf-esp32emu-cstatus-row.is-warn   { color: #9a6100; }
.pf-esp32emu-cstatus-row.is-info   { color: #2e6fa8; }
.pf-esp32emu-cstatus-row.is-val    { color: #1a2d40; }
.pf-esp32emu-cstatus-row.is-danger { color: #b03a2e; font-weight: 700; }


.pf-esp32emu-placed-item:active {
    cursor: grabbing;
}

.pf-esp32emu-port,
.pf-esp32emu-anchor {
    border: 0;
    border-radius: 50%;
    cursor: pointer;
    padding: 0;
}

.pf-esp32emu-port {
    width: 14px;
    height: 14px;
    background: #f6a53b;
    box-shadow: 0 0 0 2px #9e5a0f;
    position: absolute;
    z-index: 34;
}

.pf-esp32emu-port.is-active {
    background: #3498db;
    box-shadow: 0 0 0 2px #236a9f, 0 0 7px #3498db;
}

.pf-esp32emu-port-label {
    position: absolute;
    left: 50%;
    top: -20px;
    transform: translateX(-50%);
    font-size: 0.64rem;
    line-height: 1;
    color: #1f2d40;
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid #cdd8e8;
    border-radius: 6px;
    padding: 2px 5px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: 0.16s;
}

.pf-esp32emu-port:hover .pf-esp32emu-port-label {
    opacity: 1;
}

.pf-esp32emu-placed-item.is-esp32-mounted .pf-esp32emu-port {
    background: transparent;
    box-shadow: none;
}

.pf-esp32emu-placed-item.is-esp32-mounted .pf-esp32emu-port.is-active {
    background: rgba(52, 152, 219, 0.28);
    box-shadow: 0 0 0 2px rgba(35, 106, 159, 0.55);
}

.pf-esp32emu-anchor {
    width: 11px;
    height: 11px;
    position: absolute;
    transform: translate(-50%, -50%);
    background: #f4de5a;
    box-shadow: 0 0 0 2px #9e7d09;
    z-index: 10;
}

.wire {
    fill: none;
    stroke-linecap: round;
    pointer-events: stroke;
    cursor: pointer;
}

.wire:hover {
    filter: drop-shadow(0 0 2px rgba(255, 255, 255, 0.35));
}

.pf-esp32emu-tooltip {
    position: fixed;
    z-index: 30000;
    opacity: 0;
    pointer-events: none;
    display: inline-flex;
    align-items: center;
    padding: 7px 12px;
    width: auto;
    max-width: 360px;
    box-sizing: border-box;
    border-radius: 12px;
    border: 1px solid rgba(120, 156, 194, 0.5);
    background: linear-gradient(160deg, rgba(29, 52, 78, 0.96) 0%, rgba(19, 35, 54, 0.96) 100%);
    color: #f4f9ff;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.01em;
    box-shadow: 0 10px 22px rgba(10, 22, 37, 0.34);
    transform: translateY(4px) scale(0.985);
    transform-origin: left center;
    transition: opacity 0.14s ease, transform 0.14s ease;
    white-space: normal;
    line-height: 1.3;
    word-break: break-word;
    --pf-esp32emu-tooltip-tail-y: 50%;
}

/* Prevent cross-module/global overrides from forcing grid layout or oversized spacing. */
#pf-esp32emu-app > #pf-esp32emu-tooltip.pf-esp32emu-tooltip {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    position: fixed;
    overflow: visible;
    box-sizing: border-box;
    width: auto;
    max-width: 360px;
    padding: 7px 12px;
    border-radius: 12px;
    pointer-events: none;
    line-height: 1.3;
}

/* Root-level bubble guard: always render tail and keep it outside of the bubble box. */
#pf-esp32emu-app > #pf-esp32emu-tooltip.pf-esp32emu-tooltip::before {
    content: '';
    position: absolute;
    left: -6px;
    top: var(--pf-esp32emu-tooltip-tail-y);
    width: 10px;
    height: 10px;
    transform: translateY(-50%) rotate(45deg);
    border-left: 1px solid rgba(120, 156, 194, 0.5);
    border-bottom: 1px solid rgba(120, 156, 194, 0.5);
    border-right: 0;
    border-top: 0;
    background: #213a57;
    pointer-events: none;
}

#pf-esp32emu-app > #pf-esp32emu-tooltip.pf-esp32emu-tooltip.is-left::before {
    left: auto;
    right: -6px;
    border-left: 0;
    border-bottom: 0;
    border-right: 1px solid rgba(120, 156, 194, 0.5);
    border-top: 1px solid rgba(120, 156, 194, 0.5);
}

.pf-esp32emu-tooltip::before {
    content: '';
    position: absolute;
    left: -6px;
    top: var(--pf-esp32emu-tooltip-tail-y);
    width: 10px;
    height: 10px;
    transform: translateY(-50%) rotate(45deg);
    border-left: 1px solid rgba(120, 156, 194, 0.5);
    border-bottom: 1px solid rgba(120, 156, 194, 0.5);
    background: #213a57;
}

.pf-esp32emu-tooltip.is-left::before {
    left: auto;
    right: -6px;
    border-left: 0;
    border-bottom: 0;
    border-right: 1px solid rgba(120, 156, 194, 0.5);
    border-top: 1px solid rgba(120, 156, 194, 0.5);
}

.pf-esp32emu-tooltip.is-left {
    transform-origin: right center;
}

.pf-esp32emu-tooltip.is-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* =====================================================================
    Shared Overlay System
    - .pf-esp32emu-color-modal   component selection overlay
    - .pf-esp32emu-confirm-modal confirmation overlay
   ===================================================================== */

.pf-esp32emu-color-modal,
.pf-esp32emu-confirm-modal {
    position: fixed;
    inset: 0;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 16px;
    background: rgba(8, 14, 22, 0.55);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 26050;
}

.pf-esp32emu-color-modal.is-open,
.pf-esp32emu-confirm-modal.is-open {
    opacity: 1;
    pointer-events: auto;
}

.pf-esp32emu-color-modal > .pf-esp32emu-modal-card,
.pf-esp32emu-confirm-modal > .pf-esp32emu-modal-card {
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 48px);
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3), 0 2px 8px rgba(0,0,0,0.12);
    overflow: hidden;
}

.pf-esp32emu-color-modal > .pf-esp32emu-modal-card {
    width: min(360px, calc(100vw - 24px));
}

.pf-esp32emu-color-modal > .pf-esp32emu-modal-card.is-wire-mode {
    width: min(288px, calc(100vw - 20px));
}

.pf-esp32emu-color-modal > .pf-esp32emu-modal-card.is-resistor-mode {
    width: min(900px, calc(100vw - 32px));
}

.pf-esp32emu-color-modal > .pf-esp32emu-modal-card.is-motion-mode {
    width: min(980px, calc(100vw - 32px));
}

.pf-esp32emu-color-modal > .pf-esp32emu-modal-card.pf-esp32emu-arbeistmatte-einstellungen-card {
    width: min(620px, calc(100vw - 28px));
}

.pf-esp32emu-arbeistmatte-einstellungen-body {
    display: grid;
    gap: 12px;
}

.pf-esp32emu-arbeistmatte-einstellungen-section {
    border: 1px solid #e1e8f2;
    border-radius: 12px;
    background: #f8fbff;
    padding: 12px;
}

.pf-esp32emu-arbeistmatte-einstellungen-toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    color: #1f3247;
    cursor: pointer;
}

.pf-esp32emu-arbeistmatte-einstellungen-toggle-input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    pointer-events: none;
}

.pf-esp32emu-arbeistmatte-einstellungen-toggle-switch {
    position: relative;
    width: 46px;
    height: 26px;
    border-radius: 999px;
    background: #d4dfea;
    border: 1px solid #b9c9db;
    transition: background 160ms ease, border-color 160ms ease;
    flex-shrink: 0;
}

.pf-esp32emu-arbeistmatte-einstellungen-toggle-knob {
    position: absolute;
    left: 2px;
    top: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 2px 6px rgba(20, 38, 62, 0.2);
    transition: transform 160ms ease;
}

.pf-esp32emu-arbeistmatte-einstellungen-toggle-input:checked + .pf-esp32emu-arbeistmatte-einstellungen-toggle-switch {
    background: #2f8ac0;
    border-color: #2477a7;
}

.pf-esp32emu-arbeistmatte-einstellungen-toggle-input:checked + .pf-esp32emu-arbeistmatte-einstellungen-toggle-switch .pf-esp32emu-arbeistmatte-einstellungen-toggle-knob {
    transform: translateX(20px);
}

.pf-esp32emu-arbeistmatte-einstellungen-toggle-input:focus-visible + .pf-esp32emu-arbeistmatte-einstellungen-toggle-switch {
    outline: 2px solid rgba(47, 138, 192, 0.45);
    outline-offset: 2px;
}

.pf-esp32emu-arbeistmatte-einstellungen-toggle-label {
    line-height: 1.3;
}

.pf-esp32emu-arbeistmatte-einstellungen-history-head {
    font-size: 0.86rem;
    font-weight: 700;
    color: #223042;
    margin-bottom: 6px;
}

.pf-esp32emu-arbeistmatte-einstellungen-history-status {
    font-size: 0.82rem;
    color: var(--pf-esp32emu-overlay-muted);
    margin-bottom: 10px;
}

.pf-esp32emu-arbeistmatte-einstellungen-history-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.pf-esp32emu-settings-history-filters {
    margin-bottom: 10px;
}

.pf-esp32emu-arbeistmatte-einstellungen-history-list {
    margin: 0 0 10px;
    padding: 0 0 0 18px;
    max-height: 180px;
    overflow: auto;
}

.pf-esp32emu-arbeistmatte-einstellungen-history-item {
    margin: 0 0 6px;
    color: #2a3f58;
    font-size: 0.82rem;
}

.pf-esp32emu-arbeistmatte-einstellungen-history-jump {
    width: 100%;
    text-align: left;
    border: 1px solid #d8e4f0;
    border-radius: 8px;
    background: #ffffff;
    color: inherit;
    padding: 6px 8px;
    cursor: pointer;
    font-size: 0.82rem;
}

.pf-esp32emu-arbeistmatte-einstellungen-history-jump:hover {
    background: #f2f7fd;
    border-color: #bcd2e8;
}

.pf-esp32emu-arbeistmatte-einstellungen-history-item.is-current .pf-esp32emu-arbeistmatte-einstellungen-history-jump {
    border-color: #2f8ac0;
    background: #e8f4ff;
}

.pf-esp32emu-arbeistmatte-einstellungen-history-item.is-current {
    color: #0f2e4a;
    font-weight: 700;
}

.pf-esp32emu-arbeistmatte-einstellungen-history-item.is-empty {
    list-style: none;
    margin-left: -18px;
    color: var(--pf-esp32emu-overlay-muted);
}

.pf-esp32emu-arbeistmatte-einstellungen-history-item.is-wiring .pf-esp32emu-arbeistmatte-einstellungen-history-jump {
    border-left: 4px solid #69a9d5;
}

.pf-esp32emu-arbeistmatte-einstellungen-history-item.is-component .pf-esp32emu-arbeistmatte-einstellungen-history-jump {
    border-left: 4px solid #9c7fd8;
}

.pf-esp32emu-arbeistmatte-einstellungen-history-item.is-module .pf-esp32emu-arbeistmatte-einstellungen-history-jump {
    border-left: 4px solid #69b17d;
}

.pf-esp32emu-arbeistmatte-einstellungen-note {
    margin: 0;
    font-size: 0.86rem;
    color: var(--pf-esp32emu-overlay-muted);
}

.pf-esp32emu-color-modal > .pf-esp32emu-modal-card.is-wire-mode .pf-esp32emu-modal-header,
.pf-esp32emu-color-modal > .pf-esp32emu-modal-card.is-wire-mode .pf-esp32emu-modal-footer {
    padding-left: 12px;
    padding-right: 12px;
    padding-top: 10px;
    padding-bottom: 10px;
}

.pf-esp32emu-color-modal > .pf-esp32emu-modal-card.is-wire-mode .pf-esp32emu-modal-body {
    padding: 10px 12px;
}

.pf-esp32emu-color-modal > .pf-esp32emu-modal-card.is-wire-mode .pf-esp32emu-color-modal-grid {
    gap: 5px;
    margin-bottom: 6px;
    grid-template-columns: repeat(8, minmax(0, 1fr));
}

.pf-esp32emu-color-modal > .pf-esp32emu-modal-card.is-wire-mode .pf-esp32emu-color-modal-preview {
    padding: 8px;
    gap: 5px;
    margin-bottom: 4px;
}

.pf-esp32emu-color-modal > .pf-esp32emu-modal-card.is-wire-mode .pf-esp32emu-color-modal-custom {
    display: none;
}

.pf-esp32emu-color-modal > .pf-esp32emu-modal-card.is-wire-mode .pf-esp32emu-color-modal-grid-section-title {
    display: none;
}

.pf-esp32emu-color-modal > .pf-esp32emu-modal-card.is-wire-mode .pf-esp32emu-color-btn {
    width: 28px;
    height: 28px;
}

/* --- Modal Header --- */
.pf-esp32emu-modal-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: linear-gradient(135deg, #1b2d45 0%, #2a4168 100%);
    color: #fff;
    flex-shrink: 0;
}

.pf-esp32emu-modal-header--warning {
    background: linear-gradient(135deg, #3d1a1a 0%, #7a2e22 100%);
}

.pf-esp32emu-modal-header-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.14);
    flex-shrink: 0;
    color: #fff;
}

.pf-esp32emu-modal-header-text {
    flex: 1;
    min-width: 0;
}

.pf-esp32emu-modal-header-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
    line-height: 1.3;
}

.pf-esp32emu-modal-header-sub {
    margin: 2px 0 0;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.72);
    line-height: 1.3;
}

.pf-esp32emu-modal-close-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.pf-esp32emu-modal-close-btn:hover {
    background: rgba(255, 255, 255, 0.22);
    border-color: rgba(255, 255, 255, 0.4);
}

/* --- Modal Body --- */
.pf-esp32emu-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 18px 20px;
    min-height: 40px;
}

.pf-esp32emu-modal-body--compact {
    padding: 0;
    min-height: 0;
    flex: 0 0 0;
}

/* --- Modal Footer --- */
.pf-esp32emu-modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 20px;
    border-top: 1px solid #e8edf5;
    background: #f6f8fc;
    flex-shrink: 0;
}

/* --- Danger button variant for modals --- */
.pf-esp32emu-btn-danger {
    background: #c0392b;
    color: #fff;
    border-color: #a93226;
}

.pf-esp32emu-btn-danger:hover:not(:disabled) {
    background: #a93226;
}

.pf-esp32emu-color-modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(8, 14, 22, 0.55);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 1200;
}

.pf-esp32emu-color-modal.is-open {
    opacity: 1;
    pointer-events: auto;
}

.pf-esp32emu-sim-settings-modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: rgba(11, 16, 24, 0.58);
    backdrop-filter: blur(4px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease;
    z-index: 90;
}

.pf-esp32emu-sim-settings-modal.is-open {
    opacity: 1;
    pointer-events: auto;
}

.pf-esp32emu-sim-settings-card {
    width: min(840px, 100%);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.45);
    background: #ffffff;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.28);
    padding: 20px;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 60px);
    overflow: hidden;
}

.pf-esp32emu-sim-settings-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}

.pf-esp32emu-sim-settings-title {
    margin: 0 0 6px 0;
    font-size: 18px;
    color: #1a1a1a;
}

.pf-esp32emu-sim-settings-copy {
    margin: 0;
    color: #5f6b7a;
    font-size: 13px;
}

.pf-esp32emu-sim-settings-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid #d8e0ea;
    background: #f8fafc;
    color: #334155;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
}

.pf-esp32emu-sim-settings-close:hover {
    background: #eef4ff;
    border-color: #b8c7db;
}

.pf-esp32emu-sim-settings-summary {
    padding: 10px 14px;
    border-radius: 8px;
    background: #eef4ff;
    border: 1px solid #c2d6f5;
    margin-bottom: 14px;
}

.pf-esp32emu-sim-settings-body {
    display: grid;
    gap: 14px;
    overflow-y: auto;
    flex: 1;
    padding-right: 4px;
}

.pf-esp32emu-sim-settings-group {
    border: 1px solid #e8eff6;
    border-radius: 10px;
    padding: 10px 12px;
    background: #f8fafc;
}

.pf-esp32emu-sim-settings-group-label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #7a8fa6;
    margin-bottom: 8px;
}

.pf-esp32emu-sim-settings-summary strong {
    display: block;
    margin-bottom: 3px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #3b5fa0;
}

.pf-esp32emu-sim-settings-summary p {
    margin: 0;
    color: #1e3a6a;
    font-size: 13px;
    font-weight: 500;
}

.pf-esp32emu-sim-settings-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(140px, 1fr));
    gap: 10px;
}

.pf-esp32emu-sim-settings-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border: 1px solid #d8e0ea;
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    user-select: none;
    font-size: 13px;
    color: #2d3748;
}

.pf-esp32emu-sim-settings-toggle input {
    width: 16px;
    height: 16px;
    margin: 0;
}

.pf-esp32emu-sim-settings-toggle:hover {
    border-color: #0066cc;
    box-shadow: 0 2px 10px rgba(0, 102, 204, 0.08);
}

.pf-esp32emu-sim-settings-toggle-badge {
    margin-left: auto;
    font-size: 11px;
    color: #7a8fa6;
    white-space: nowrap;
}

.pf-esp32emu-sim-settings-iface-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.pf-esp32emu-sim-settings-iface-list .pf-esp32emu-sim-settings-toggle {
    width: 100%;
}

.pf-esp32emu-sim-settings-groups {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.pf-esp32emu-sim-settings-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 6px;
}

.pf-esp32emu-sim-settings-field:first-child {
    margin-top: 0;
}

.pf-esp32emu-sim-settings-field-label {
    font-size: 12px;
    font-weight: 600;
    color: #374151;
}

.pf-esp32emu-sim-settings-input {
    width: 100%;
    border: 1px solid #d8e0ea;
    border-radius: 7px;
    padding: 7px 10px;
    font-size: 13px;
    color: #1f2d40;
    background: #fff;
    outline: none;
    font-family: inherit;
}

.pf-esp32emu-sim-settings-input:focus {
    border-color: #0066cc;
    box-shadow: 0 0 0 2px rgba(0, 102, 204, 0.12);
}

.pf-esp32emu-sim-settings-input-hint {
    font-size: 11px;
    color: #7a8fa6;
    line-height: 1.4;
}

.pf-esp32emu-sim-settings-label {
    font-size: 12px;
    font-weight: 700;
    color: #2b3e55;
    letter-spacing: 0.01em;
}

.pf-esp32emu-sim-settings-toggle {
    position: relative;
    gap: 10px;
}

.pf-esp32emu-sim-settings-toggle input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    pointer-events: none;
}

.pf-esp32emu-sim-settings-toggle-track {
    width: 46px;
    height: 24px;
    border-radius: 999px;
    background: linear-gradient(180deg, #8ea2b8 0%, #6f859d 100%);
    box-shadow: inset 0 0 0 1px rgba(10, 28, 45, 0.24);
    position: relative;
    flex: 0 0 46px;
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

.pf-esp32emu-sim-settings-toggle-track::after {
    content: '';
    position: absolute;
    left: 2px;
    top: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(180deg, #ffffff 0%, #e6eef8 100%);
    box-shadow: 0 2px 6px rgba(10, 16, 24, 0.3);
    transition: transform 0.2s ease;
}

.pf-esp32emu-sim-settings-toggle-label {
    font-size: 13px;
    font-weight: 600;
    color: #1f2d40;
}

.pf-esp32emu-sim-settings-toggle input[type="checkbox"]:checked + .pf-esp32emu-sim-settings-toggle-track {
    background: linear-gradient(180deg, #2ecf90 0%, #1ea86f 100%);
    box-shadow: inset 0 0 0 1px rgba(10, 92, 62, 0.22), 0 0 0 2px rgba(30, 168, 111, 0.2);
}

.pf-esp32emu-sim-settings-toggle input[type="checkbox"]:checked + .pf-esp32emu-sim-settings-toggle-track::after {
    transform: translateX(22px);
}

.pf-esp32emu-sim-settings-toggle input[type="checkbox"]:focus-visible + .pf-esp32emu-sim-settings-toggle-track {
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.22);
}

.pf-esp32emu-psu-modal .pf-esp32emu-modal-card {
    width: min(640px, calc(100vw - 32px));
}

.pf-esp32emu-psu-modal .pf-esp32emu-modal-body {
    padding-top: 10px;
}

.pf-esp32emu-psu-modal .pf-esp32emu-sim-settings-grid {
    grid-template-columns: 1fr;
    gap: 14px;
}

.pf-esp32emu-psu-dial-row {
    display: grid;
    grid-template-columns: 96px minmax(84px, 1fr) minmax(104px, 128px);
    align-items: center;
    gap: 10px;
}

.pf-esp32emu-psu-dial {
    --pf-esp32emu-psu-dial-angle: -138deg;
    --pf-esp32emu-psu-dial-pct: 0;
    position: relative;
    width: 88px;
    height: 88px;
    border-radius: 50%;
    border: 1px solid color-mix(in srgb, var(--pf-esp32emu-overlay-border) 78%, #8699af 22%);
    background: radial-gradient(circle at 33% 28%, #fdfefe 0%, #e7edf6 40%, #cad4e1 100%);
    box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.8), inset 0 -5px 8px rgba(95, 122, 153, 0.28), 0 6px 16px rgba(25, 45, 68, 0.2);
    cursor: ns-resize;
    padding: 0;
    outline: none;
    transition: transform 0.15s ease, box-shadow 0.2s ease;
}

.pf-esp32emu-psu-dial:hover {
    transform: translateY(-1px) scale(1.015);
    box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.82), inset 0 -6px 9px rgba(95, 122, 153, 0.32), 0 8px 18px rgba(25, 45, 68, 0.24);
}

.pf-esp32emu-psu-dial.is-dragging {
    cursor: grabbing;
    transform: scale(0.985);
}

.pf-esp32emu-psu-dial:focus-visible {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--pf-esp32emu-overlay-accent) 44%, transparent 56%), inset 0 2px 4px rgba(255, 255, 255, 0.78), inset 0 -5px 8px rgba(95, 122, 153, 0.3);
}

.pf-esp32emu-psu-dial-scale {
    position: absolute;
    inset: 6px;
    border-radius: 50%;
    border: 4px solid transparent;
    border-top-color: color-mix(in srgb, var(--pf-esp32emu-overlay-muted) 62%, #cfd8e4 38%);
    border-right-color: color-mix(in srgb, var(--pf-esp32emu-overlay-muted) 62%, #cfd8e4 38%);
    border-bottom-color: color-mix(in srgb, var(--pf-esp32emu-overlay-muted) 62%, #cfd8e4 38%);
    border-left-color: color-mix(in srgb, var(--pf-esp32emu-overlay-panel) 70%, #eef4fb 30%);
    opacity: 0.66;
}

.pf-esp32emu-psu-dial-scale-inner {
    inset: 14px;
    border-width: 2px;
    opacity: 0.38;
}

.pf-esp32emu-psu-dial-marker {
    position: absolute;
    left: 50%;
    top: 8px;
    width: 6px;
    height: 22px;
    margin-left: -3px;
    border-radius: 999px;
    background: linear-gradient(180deg, color-mix(in srgb, var(--pf-esp32emu-overlay-accent) 85%, #ffffff 15%) 0%, color-mix(in srgb, var(--pf-esp32emu-overlay-accent) 70%, #0a4f72 30%) 100%);
    transform-origin: 50% 36px;
    transform: rotate(var(--pf-esp32emu-psu-dial-angle));
    box-shadow: 0 0 8px color-mix(in srgb, var(--pf-esp32emu-overlay-accent) 30%, transparent 70%);
    transition: transform 0.12s ease-out;
}

.pf-esp32emu-psu-dial-cap {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 34px;
    height: 34px;
    margin-left: -17px;
    margin-top: -17px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 26%, #f9fdff 0%, #dae4f2 46%, #b5c4d7 100%);
    box-shadow: inset 0 -2px 4px rgba(55, 73, 96, 0.25), 0 1px 4px rgba(0, 0, 0, 0.18);
}

.pf-esp32emu-psu-dial-value {
    font-family: Consolas, 'Courier New', monospace;
    font-weight: 700;
    font-size: 16px;
    letter-spacing: 0.02em;
    color: color-mix(in srgb, var(--pf-esp32emu-overlay-accent) 84%, #1d2d44 16%);
    background: linear-gradient(180deg, color-mix(in srgb, var(--pf-esp32emu-overlay-panel) 70%, #f6f9fe 30%), color-mix(in srgb, var(--pf-esp32emu-overlay-panel) 88%, #dbe5f2 12%));
    border: 1px solid var(--pf-esp32emu-overlay-border);
    border-radius: 8px;
    padding: 8px 10px;
    text-align: center;
    min-width: 96px;
}

.pf-esp32emu-psu-inline-input {
    text-align: right;
    font-family: Consolas, 'Courier New', monospace;
    font-weight: 700;
    color: var(--pf-esp32emu-overlay-text);
}

.pf-esp32emu-psu-dial.is-turning .pf-esp32emu-psu-dial-marker {
    animation: pf-esp32emu-psu-dial-pulse 170ms ease-out;
}

.pf-esp32emu-psu-modal .pf-esp32emu-sim-settings-field {
    padding: 10px;
    border-radius: 12px;
    border: 1px solid color-mix(in srgb, var(--pf-esp32emu-overlay-border) 86%, transparent 14%);
    background: linear-gradient(165deg, color-mix(in srgb, var(--pf-esp32emu-overlay-input) 78%, var(--pf-esp32emu-overlay-panel) 22%), color-mix(in srgb, var(--pf-esp32emu-overlay-panel) 90%, #ffffff 10%));
}

.pf-esp32emu-psu-modal .pf-esp32emu-sim-settings-toggle {
    margin-top: 4px;
}

.pf-esp32emu-psu-modal .pf-esp32emu-modal-header {
    background: linear-gradient(132deg, #1e3958 0%, #35779e 100%);
}

.pf-esp32emu-psu-modal .pf-esp32emu-modal-card.is-strong-psu .pf-esp32emu-modal-header {
    background: linear-gradient(132deg, #4a1616 0%, #8a3f1d 100%);
}

#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-psu-modal .pf-esp32emu-sim-settings-label,
#pf-esp32emu-app.is-dark-theme .pf-esp32emu-psu-modal .pf-esp32emu-sim-settings-label {
    color: #d4e1ef;
}

#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-psu-modal .pf-esp32emu-sim-settings-toggle-label,
#pf-esp32emu-app.is-dark-theme .pf-esp32emu-psu-modal .pf-esp32emu-sim-settings-toggle-label {
    color: #d9e5f3;
}

#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-psu-modal .pf-esp32emu-sim-settings-toggle-track,
#pf-esp32emu-app.is-dark-theme .pf-esp32emu-psu-modal .pf-esp32emu-sim-settings-toggle-track {
    background: linear-gradient(180deg, #51647a 0%, #3f5064 100%);
}

#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-psu-modal .pf-esp32emu-sim-settings-toggle-track::after,
#pf-esp32emu-app.is-dark-theme .pf-esp32emu-psu-modal .pf-esp32emu-sim-settings-toggle-track::after {
    background: linear-gradient(180deg, #f8fbff 0%, #cfd9e5 100%);
}

#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-psu-modal .pf-esp32emu-psu-dial,
#pf-esp32emu-app.is-dark-theme .pf-esp32emu-psu-modal .pf-esp32emu-psu-dial {
    background: radial-gradient(circle at 30% 24%, #3e4e62 0%, #2b394a 44%, #1a2431 100%);
    border-color: color-mix(in srgb, var(--pf-esp32emu-overlay-border) 85%, #5f748b 15%);
    box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.08), inset 0 -5px 8px rgba(4, 8, 14, 0.52), 0 8px 18px rgba(0, 0, 0, 0.42);
}

#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-psu-modal .pf-esp32emu-psu-dial-cap,
#pf-esp32emu-app.is-dark-theme .pf-esp32emu-psu-modal .pf-esp32emu-psu-dial-cap {
    background: radial-gradient(circle at 30% 24%, #8ea1b8 0%, #60748b 45%, #364759 100%);
    box-shadow: inset 0 -2px 4px rgba(10, 20, 30, 0.4), 0 1px 4px rgba(0, 0, 0, 0.32);
}

@keyframes pf-esp32emu-psu-dial-pulse {
    0% {
        transform: rotate(var(--pf-esp32emu-psu-dial-angle)) scaleY(1);
        filter: brightness(1);
    }
    50% {
        transform: rotate(var(--pf-esp32emu-psu-dial-angle)) scaleY(1.08);
        filter: brightness(1.2);
    }
    100% {
        transform: rotate(var(--pf-esp32emu-psu-dial-angle)) scaleY(1);
        filter: brightness(1);
    }
}

@media (max-width: 720px) {
    .pf-esp32emu-psu-dial-row {
        grid-template-columns: 88px 1fr;
        grid-template-areas:
            'dial value'
            'input input';
        gap: 8px;
    }

    .pf-esp32emu-psu-dial-row .pf-esp32emu-psu-dial { grid-area: dial; }
    .pf-esp32emu-psu-dial-row .pf-esp32emu-psu-dial-value { grid-area: value; }
    .pf-esp32emu-psu-dial-row .pf-esp32emu-psu-inline-input { grid-area: input; }
}

.pf-esp32emu-sim-settings-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 16px;
}

.pf-esp32emu-btn-secondary {
    background: #eef2f7;
    color: #22303f;
    box-shadow: none;
}

.pf-esp32emu-btn-secondary:hover:not(:disabled) {
    background: #dde6f1;
}

.pf-esp32emu-confirm-modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(8, 14, 22, 0.55);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    z-index: 1200;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease;
}

.pf-esp32emu-confirm-modal.is-open {
    opacity: 1;
    pointer-events: auto;
}

.pf-esp32emu-color-modal-title {
    /* title now styled by .pf-esp32emu-modal-header-title */
    margin: 0;
}

.pf-esp32emu-color-modal-copy {
    /* copy now styled by .pf-esp32emu-modal-header-sub */
    margin: 0;
}

.pf-esp32emu-color-modal-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin: 0 0 10px;
}

.pf-esp32emu-color-modal-grid.is-resistor {
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.pf-esp32emu-color-modal-grid.is-led {
    grid-template-columns: repeat(auto-fit, minmax(136px, 1fr));
}

.pf-esp32emu-color-modal-grid.is-can {
    grid-template-columns: repeat(auto-fit, minmax(124px, 1fr));
    gap: 6px;
}

.pf-esp32emu-color-modal-preview {
    grid-column: 1 / -1;
    display: grid;
    gap: 8px;
    margin: 0 0 8px;
    padding: 12px;
    border: 1px solid var(--pf-esp32emu-border);
    border-radius: 12px;
    background: #f8fafc;
}

.pf-esp32emu-color-modal-preview-wire {
    height: 16px;
    border-radius: 999px;
    background: #2c3e50;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 1px 2px rgba(0, 0, 0, 0.12);
}

.pf-esp32emu-color-modal-preview-label {
    font-size: 0.78rem;
    color: var(--pf-esp32emu-muted);
    font-weight: 700;
    letter-spacing: 0.02em;
}

.pf-esp32emu-color-modal-grid-section-title {
    grid-column: 1 / -1;
    font-size: 0.78rem;
    font-weight: 800;
    color: var(--pf-esp32emu-muted);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    margin-top: 0.25rem;
}

.pf-esp32emu-siggen-editor {
    grid-column: 1 / -1;
    display: grid;
    gap: 9px;
    padding: 10px;
    border: 1px solid #d7dee8;
    border-radius: 10px;
    background: #f7faff;
}

.pf-esp32emu-siggen-field {
    display: grid;
    gap: 4px;
}

.pf-esp32emu-siggen-field > span {
    font-size: 0.74rem;
    font-weight: 700;
    color: #51657c;
}

.pf-esp32emu-siggen-field > input,
.pf-esp32emu-siggen-field > select {
    height: 34px;
    border: 1px solid #c7d3e2;
    border-radius: 8px;
    padding: 0 10px;
    background: #ffffff;
    color: #213548;
    font-size: 0.82rem;
}

.pf-esp32emu-siggen-switch {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: #355069;
    font-weight: 700;
}

.pf-esp32emu-siggen-preview {
    font-size: 0.76rem;
    color: #49627d;
    padding: 8px 10px;
    border-radius: 8px;
    background: #edf3fb;
    border: 1px solid #d8e2ee;
}

.pf-esp32emu-siggen-overlay {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    background: rgba(5, 10, 18, 0.58);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 1400;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease;
}

.pf-esp32emu-siggen-overlay.is-open {
    opacity: 1;
    pointer-events: auto;
}

.pf-esp32emu-siggen-overlay-card {
    width: min(860px, calc(100vw - 24px));
    max-height: calc(100vh - 24px);
    overflow: auto;
    border-radius: 14px;
    border: 1px solid #2f4e67;
    background: linear-gradient(180deg, #14314c 0%, #0f2438 100%);
    box-shadow: 0 22px 54px rgba(4, 10, 18, 0.5);
    color: #e6f0fa;
}

.pf-esp32emu-siggen-overlay-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-bottom: 1px solid rgba(164, 200, 232, 0.2);
}

.pf-esp32emu-siggen-overlay-head h3 {
    margin: 0;
    font-size: 1.03rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.pf-esp32emu-siggen-overlay-body {
    display: grid;
    gap: 12px;
    padding: 12px 14px;
}

.pf-esp32emu-siggen-screen {
    border: 1px solid #2f506d;
    border-radius: 10px;
    background: linear-gradient(180deg, #0b1c2d 0%, #0b1622 100%);
    padding: 10px;
}

.pf-esp32emu-siggen-screen-svg {
    width: 100%;
    height: 118px;
    display: block;
}

.pf-esp32emu-siggen-grid {
    stroke: rgba(120, 196, 255, 0.3);
    stroke-width: 1;
}

.pf-esp32emu-siggen-wave {
    stroke: #53c9ff;
    stroke-width: 2.2;
    fill: none;
}

.pf-esp32emu-siggen-screen-info {
    margin-top: 8px;
    font-size: 0.82rem;
    color: #c7e2f8;
}

.pf-esp32emu-siggen-knob-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}

.pf-esp32emu-siggen-knob {
    display: grid;
    gap: 6px;
    padding: 8px;
    border: 1px solid #355b79;
    border-radius: 10px;
    background: rgba(9, 25, 40, 0.85);
}

.pf-esp32emu-siggen-knob > span {
    font-size: 0.74rem;
    color: #bdd9ef;
    font-weight: 700;
}

.pf-esp32emu-siggen-knob input[type="range"] {
    width: 100%;
}

.pf-esp32emu-siggen-knob output {
    font-size: 0.73rem;
    color: #90d8ff;
}

.pf-esp32emu-siggen-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.pf-esp32emu-siggen-row label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #d3e9fb;
    font-size: 0.82rem;
}

.pf-esp32emu-siggen-row select {
    height: 32px;
    border-radius: 8px;
    border: 1px solid #3f6685;
    background: #17344e;
    color: #eef7ff;
    padding: 0 8px;
}

.pf-esp32emu-siggen-toggle input {
    accent-color: #4fc8ff;
}

.pf-esp32emu-siggen-overlay-foot {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 10px 14px 14px;
    border-top: 1px solid rgba(164, 200, 232, 0.2);
}

@media (max-width: 760px) {
    .pf-esp32emu-siggen-knob-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.pf-esp32emu-color-btn {
    width: 40px;
    height: 40px;
    margin: 0 auto;
    border-radius: 50%;
    border: 2px solid #eee;
    cursor: pointer;
    transition: transform 0.1s ease, border-color 0.1s ease;
}

.pf-esp32emu-color-btn.is-light {
    box-shadow: inset 0 0 0 1px #ccc;
}

.pf-esp32emu-color-btn:hover {
    transform: scale(1.1);
    border-color: #999;
}

.pf-esp32emu-choice-btn {
    display: grid;
    gap: 6px;
    justify-items: center;
    padding: 8px 6px;
    border: 1px solid #d7dee8;
    border-radius: 8px;
    background: #f7faff;
    color: #1f2d40;
    cursor: pointer;
    text-align: left;
}

.pf-esp32emu-choice-btn:hover {
    border-color: #7f98b8;
    background: #eef4ff;
}

.pf-esp32emu-choice-btn.is-selected {
    border-color: #2f6fb2;
    box-shadow: 0 0 0 2px rgba(47, 111, 178, 0.14);
}

.pf-esp32emu-choice-btn-led {
    align-content: start;
    justify-items: start;
    padding: 8px;
    gap: 4px;
}

.pf-esp32emu-choice-btn-led .pf-esp32emu-choice-preview {
    min-height: 46px;
}

.pf-esp32emu-choice-btn-led .pf-esp32emu-choice-preview svg {
    width: 100%;
    height: 44px;
}

.pf-esp32emu-choice-preview {
    display: block;
    width: 100%;
    min-height: 34px;
}

.pf-esp32emu-choice-preview svg {
    width: 100%;
    height: 30px;
}

.pf-esp32emu-choice-label {
    font-size: 0.75rem;
    font-weight: 700;
}

.pf-esp32emu-choice-meta,
.pf-esp32emu-choice-usage {
    display: block;
    font-size: 0.68rem;
    line-height: 1.35;
    color: #52657d;
}

.pf-esp32emu-choice-usage {
    color: #2e4d68;
}

.pf-esp32emu-color-modal-help {
    margin: 0 0 8px;
}

.pf-esp32emu-resistor-help {
    display: grid;
    gap: 10px;
    padding: 12px;
    border: 1px solid #dce5ef;
    border-radius: 10px;
    background: #f8fbff;
}

.pf-esp32emu-resistor-help-summary,
.pf-esp32emu-resistor-help-example {
    display: grid;
    gap: 4px;
    font-size: 0.76rem;
    line-height: 1.45;
    color: #33465c;
}

.pf-esp32emu-resistor-help-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 8px;
}

.pf-esp32emu-resistor-help-card {
    display: grid;
    gap: 4px;
    padding: 10px;
    border-radius: 8px;
    background: #ffffff;
    border: 1px solid #e1e8f0;
    color: #41566d;
    font-size: 0.72rem;
    line-height: 1.4;
}

.pf-esp32emu-led-help {
    gap: 8px;
    padding: 10px;
}

.pf-esp32emu-led-help .pf-esp32emu-resistor-help-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
}

.pf-esp32emu-led-help .pf-esp32emu-resistor-help-card {
    padding: 8px;
    font-size: 0.69rem;
    line-height: 1.3;
}

.pf-esp32emu-motion-help {
    gap: 10px;
    padding: 12px;
}

.pf-esp32emu-motion-help .pf-esp32emu-resistor-help-summary {
    font-size: 0.82rem;
    line-height: 1.5;
}

.pf-esp32emu-motion-help-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.pf-esp32emu-motion-help .pf-esp32emu-resistor-help-card {
    font-size: 0.75rem;
    line-height: 1.45;
}

.pf-esp32emu-motion-help .pf-esp32emu-resistor-help-example {
    font-size: 0.79rem;
    line-height: 1.48;
}

@media (max-width: 760px) {
    .pf-esp32emu-motion-help-grid {
        grid-template-columns: 1fr;
    }
}

.pf-esp32emu-choice-btn-led .pf-esp32emu-choice-label {
    font-size: 0.71rem;
}

.pf-esp32emu-choice-btn-led .pf-esp32emu-choice-meta {
    font-size: 0.64rem;
    line-height: 1.25;
}

.pf-esp32emu-choice-btn-can .pf-esp32emu-choice-preview {
    min-height: 52px;
}

.pf-esp32emu-choice-btn-can .pf-esp32emu-choice-preview svg {
    height: 50px;
}

.pf-esp32emu-choice-btn-can {
    padding: 7px 7px;
    gap: 3px;
}

.pf-esp32emu-choice-btn-can .pf-esp32emu-choice-label {
    font-size: 0.68rem;
}

.pf-esp32emu-choice-btn-can .pf-esp32emu-choice-meta,
.pf-esp32emu-choice-btn-can .pf-esp32emu-choice-usage {
    font-size: 0.61rem;
    line-height: 1.22;
}

.pf-esp32emu-choice-btn-display {
    gap: 6px;
    padding: 9px 9px;
    border-radius: 12px;
    border-width: 1px;
    background: linear-gradient(165deg, #f7fbff, #edf4fb);
    transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.pf-esp32emu-choice-btn-display:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 16px rgba(21, 42, 68, 0.10);
}

.pf-esp32emu-choice-btn-display .pf-esp32emu-choice-preview {
    min-height: 58px;
}

.pf-esp32emu-choice-btn-display .pf-esp32emu-choice-preview svg {
    height: 54px;
}

.pf-esp32emu-choice-btn-display .pf-esp32emu-choice-label {
    font-size: 0.72rem;
}

.pf-esp32emu-choice-btn-display .pf-esp32emu-choice-meta {
    font-size: 0.64rem;
    letter-spacing: 0.02em;
}

.pf-esp32emu-choice-btn-display.is-oled {
    border-color: color-mix(in srgb, #0a9ad1 35%, #c5d9eb 65%);
    background: linear-gradient(162deg, #f2fbff, #e7f3fb);
}

.pf-esp32emu-choice-btn-display.is-oled.is-selected {
    border-color: #0d8dc3;
    box-shadow: 0 0 0 2px rgba(13, 141, 195, 0.15), 0 8px 18px rgba(10, 88, 125, 0.16);
}

.pf-esp32emu-choice-btn-display.is-lcd {
    border-color: color-mix(in srgb, #4f8a57 34%, #c8d9ca 66%);
    background: linear-gradient(162deg, #f4fbf4, #ebf4ed);
}

.pf-esp32emu-choice-btn-display.is-lcd.is-selected {
    border-color: #4b8d54;
    box-shadow: 0 0 0 2px rgba(75, 141, 84, 0.14), 0 8px 18px rgba(46, 92, 54, 0.15);
}

.pf-esp32emu-can-preset-row {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.pf-esp32emu-can-preset-btn {
    font-size: 0.63rem;
    line-height: 1.2;
    padding: 5px 7px;
}

.pf-esp32emu-monitor-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 700;
    margin-bottom: 7px;
}

.pf-esp32emu-sim-hint {
    margin-bottom: 8px;
    padding: 8px 10px;
    border-radius: 9px;
    border: 1px solid #c9d5e6;
    background: #f4f8fe;
    color: #355170;
    font-size: 0.78rem;
    line-height: 1.35;
}

.pf-esp32emu-sim-hint.is-warning {
    border-color: #e2c6c2;
    background: #fff1ef;
    color: #8f3027;
}

.pf-esp32emu-sim-hint.is-ok {
    border-color: #bddfc9;
    background: #eef9f2;
    color: #1f673d;
}

.pf-esp32emu-sim-hint.is-live {
    border-color: #b7d5eb;
    background: #eef7ff;
    color: #1f5686;
}

.pf-esp32emu-monitor-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 6px;
}

.pf-esp32emu-mf-chip {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    border-radius: 5px;
    padding: 2px 5px;
    font-size: 0.72rem;
    font-weight: 600;
    background: #eef3fb;
    border: 1px solid #c8d6ea;
    color: #374151;
    user-select: none;
    gap: 3px;
    transition: opacity 0.15s;
}

.pf-esp32emu-mf-chip:has(.pf-esp32emu-mf-cb:not(:checked)) {
    opacity: 0.38;
}

.pf-esp32emu-mf-cb {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

.pf-esp32emu-mf-icon {
    width: 14px;
    height: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.pf-esp32emu-mf-icon svg {
    width: 100%;
    height: 100%;
}

.pf-esp32emu-mf-info      { border-color: #93bfef; background: #e8f2ff; }
.pf-esp32emu-mf-module    { border-color: #8fd2a7; background: #eaf8f0; }
.pf-esp32emu-mf-warn      { border-color: #f5c842; background: #fff8dc; }
.pf-esp32emu-mf-error     { border-color: #f59393; background: #fff0f0; }
.pf-esp32emu-mf-critical  { border-color: #f07000; background: #fff0e0; }
.pf-esp32emu-mf-nice      { border-color: #b8e6b0; background: #efffee; }
.pf-esp32emu-mf-wiring    { border-color: #a9d4f5; background: #e8f7ff; }
.pf-esp32emu-mf-component { border-color: #c8b4f0; background: #f5eeff; }
.pf-esp32emu-mf-behavior  { border-color: #a0d0a0; background: #eaf7ea; }
.pf-esp32emu-mf-pfnote    { border-color: #e0c080; background: #fffbe8; }

/* Console line severity colors */
.pf-esp32emu-sev-warn     { color: #e8c430; }
.pf-esp32emu-sev-error    { color: #ff6b6b; }
.pf-esp32emu-sev-critical { color: #ff9340; font-weight: 700; }
.pf-esp32emu-sev-nice     { color: #7fdf7f; }
.pf-esp32emu-sev-wiring   { color: #7ac8f0; }
.pf-esp32emu-sev-component { color: #c8a8f0; }
.pf-esp32emu-sev-behavior { color: #60e060; }
.pf-esp32emu-sev-pfnote   { color: #f0c060; }
/* info keeps default console green */

.pf-esp32emu-console {
    height: 260px;
    max-height: 260px;
    border-radius: 10px;
    border: 1px solid #1f2834;
    padding: 10px;
    background: #0d1117;
    color: #46f07f;
    font-size: 0.76rem;
    font-family: Consolas, Monaco, monospace;
    overflow: auto;
}

.pf-esp32emu-console-line {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 3px;
}

.pf-esp32emu-console-line[hidden] {
    display: none !important;
}

.pf-esp32emu-console-sev-icon {
    width: 14px;
    height: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-top: 1px;
    flex-shrink: 0;
}

.pf-esp32emu-console-sev-icon svg {
    width: 100%;
    height: 100%;
}

.pf-esp32emu-console-message {
    min-width: 0;
    overflow-wrap: anywhere;
}

.pf-esp32emu-sim-float {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 1100;
    width: min(620px, calc(100vw - 24px));
    min-width: 420px;
    min-height: 220px;
    max-width: calc(100vw - 16px);
    max-height: calc(100vh - 16px);
    border: 1px solid rgba(167, 184, 205, 0.45);
    border-radius: 14px;
    background: rgba(13, 19, 29, 0.92);
    box-shadow: 0 20px 44px rgba(7, 11, 17, 0.42);
    padding: 11px;
    color: #e7effa;
    backdrop-filter: blur(6px);
    display: none;
    flex-direction: column;
    gap: 0;
}

.pf-esp32emu-sim-float.is-open {
    display: flex;
}

.pf-esp32emu-sim-float.is-floating-placed {
    transform: none;
}

.pf-esp32emu-sim-float-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    font-size: 0.79rem;
    cursor: grab;
    user-select: none;
    border: 1px dashed rgba(148, 198, 255, 0.34);
    border-radius: 10px;
    padding: 7px 9px;
    background: linear-gradient(90deg, rgba(22, 39, 60, 0.64), rgba(16, 29, 45, 0.42));
}

.pf-esp32emu-sim-float-head:hover {
    border-color: rgba(148, 198, 255, 0.58);
    box-shadow: inset 0 0 0 1px rgba(142, 184, 240, 0.2);
}

.pf-esp32emu-sim-float-title {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.pf-esp32emu-sim-float-title-icon {
    width: 17px;
    height: 17px;
    display: inline-flex;
    color: #99c7ff;
}

.pf-esp32emu-sim-float-title-icon svg {
    width: 100%;
    height: 100%;
}

.pf-esp32emu-sim-float-drag-hint {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 8px;
    border-radius: 999px;
    border: 1px solid rgba(154, 201, 255, 0.45);
    background: rgba(71, 116, 168, 0.2);
    color: #cfe6ff;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.pf-esp32emu-sim-float-drag-icon {
    width: 12px;
    height: 12px;
    display: inline-flex;
}

.pf-esp32emu-sim-float-drag-icon svg {
    width: 100%;
    height: 100%;
}

.pf-esp32emu-sim-float.is-dragging .pf-esp32emu-sim-float-head {
    cursor: grabbing;
    border-style: solid;
    border-color: rgba(134, 189, 255, 0.82);
    box-shadow: 0 0 0 2px rgba(83, 140, 207, 0.26), inset 0 0 0 1px rgba(165, 215, 255, 0.28);
}

.pf-esp32emu-sim-float-status {
    color: #94b6df;
    font-size: 0.74rem;
    margin-left: auto;
}

.pf-esp32emu-sim-float-head-actions {
    display: inline-flex;
    align-items: center;
}

.pf-esp32emu-sim-float-head-btn {
    width: 28px;
    height: 28px;
    border: 1px solid rgba(184, 204, 230, 0.34);
    border-radius: 8px;
    color: #d8e8ff;
    background: rgba(255, 255, 255, 0.06);
    font-size: 1rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
}

.pf-esp32emu-sim-float-head-btn:hover {
    background: rgba(142, 184, 240, 0.18);
    border-color: #8eb8f0;
}

.pf-esp32emu-sim-float-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.pf-esp32emu-sim-float-controls .pf-esp32emu-btn {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(184, 204, 230, 0.24);
    color: #e5edf7;
}

.pf-esp32emu-sim-float-controls .pf-esp32emu-btn#pf-esp32emu-btn-sim-stop {
    background: rgba(138, 42, 38, 0.28);
    border-color: rgba(239, 98, 88, 0.48);
    color: #ffd8d4;
}

.pf-esp32emu-sim-float-controls .pf-esp32emu-btn#pf-esp32emu-btn-sim-stop.is-enabled {
    background: linear-gradient(180deg, rgba(215, 75, 66, 0.78), rgba(169, 42, 34, 0.92));
    border-color: #ff8479;
    color: #fff4f2;
}

.pf-esp32emu-sim-float-controls .pf-esp32emu-btn#pf-esp32emu-btn-sim-restart {
    background: rgba(148, 122, 32, 0.28);
    border-color: rgba(245, 205, 88, 0.48);
    color: #fff2c8;
}

.pf-esp32emu-sim-float-controls .pf-esp32emu-btn#pf-esp32emu-btn-sim-restart.is-enabled {
    background: linear-gradient(180deg, rgba(240, 206, 79, 0.86), rgba(181, 144, 22, 0.92));
    border-color: #ffe486;
    color: #2d2507;
}

.pf-esp32emu-sim-float-controls .pf-esp32emu-btn#pf-esp32emu-btn-sim-pause {
    background: rgba(42, 126, 57, 0.28);
    border-color: rgba(102, 218, 133, 0.48);
    color: #d7f9e0;
}

.pf-esp32emu-sim-float-controls .pf-esp32emu-btn#pf-esp32emu-btn-sim-pause.is-enabled {
    background: linear-gradient(180deg, rgba(73, 183, 95, 0.85), rgba(35, 129, 51, 0.92));
    border-color: #8ce6a3;
    color: #f2fff5;
}

.pf-esp32emu-sim-float-controls .pf-esp32emu-btn#pf-esp32emu-btn-sim-pause.is-active {
    box-shadow: inset 0 0 0 1px rgba(231, 255, 239, 0.45), 0 0 0 2px rgba(54, 187, 87, 0.24);
}

.pf-esp32emu-sim-float-controls .pf-esp32emu-btn:hover:not(:disabled) {
    border-color: #8eb8f0;
    background: rgba(142, 184, 240, 0.18);
    color: #ffffff;
}

.pf-esp32emu-sim-float-controls .pf-esp32emu-btn#pf-esp32emu-btn-sim-stop.is-enabled:hover:not(:disabled) {
    border-color: #ff9a90;
    background: linear-gradient(180deg, rgba(232, 94, 84, 0.9), rgba(180, 48, 39, 0.95));
    color: #fff9f8;
}

.pf-esp32emu-sim-float-controls .pf-esp32emu-btn#pf-esp32emu-btn-sim-restart.is-enabled:hover:not(:disabled) {
    border-color: #ffe8a0;
    background: linear-gradient(180deg, rgba(245, 214, 101, 0.92), rgba(191, 156, 33, 0.95));
    color: #2b2408;
}

.pf-esp32emu-sim-float-controls .pf-esp32emu-btn#pf-esp32emu-btn-sim-pause.is-enabled:hover:not(:disabled) {
    border-color: #a1f0b5;
    background: linear-gradient(180deg, rgba(87, 197, 110, 0.92), rgba(42, 142, 58, 0.95));
    color: #f5fff7;
}

.pf-esp32emu-sim-float-controls .pf-esp32emu-btn:disabled {
    opacity: 0.42;
    cursor: not-allowed;
}

.pf-esp32emu-sim-float-resize-handle {
    position: absolute;
    right: 7px;
    bottom: 7px;
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: rgba(172, 206, 245, 0.82);
    background: rgba(16, 30, 45, 0.72);
    border: 1px solid rgba(172, 206, 245, 0.34);
    border-radius: 5px;
    cursor: nwse-resize;
    user-select: none;
}

.pf-esp32emu-sim-float-resize-handle svg {
    width: 12px;
    height: 12px;
}

.pf-esp32emu-sim-float-resize-handle:hover {
    color: #e3f3ff;
    border-color: rgba(191, 225, 255, 0.72);
    background: rgba(41, 72, 104, 0.85);
}

.pf-esp32emu-sim-float.is-resizing {
    box-shadow: 0 22px 48px rgba(7, 11, 17, 0.46), 0 0 0 2px rgba(140, 193, 255, 0.28);
}

.pf-esp32emu-sim-float.is-resizing .pf-esp32emu-sim-float-resize-handle {
    border-color: rgba(215, 237, 255, 0.95);
    background: rgba(57, 97, 140, 0.9);
}

.pf-esp32emu-sim-float-meta {
    margin-top: 10px;
    border-top: 1px solid rgba(150, 173, 201, 0.28);
    padding-top: 9px;
    display: grid;
    gap: 8px;
    min-height: 0;
    flex: 1 1 auto;
}

.pf-esp32emu-sim-float-hint {
    border: 1px solid rgba(158, 198, 235, 0.34);
    background: rgba(31, 53, 79, 0.45);
    color: #cfe7ff;
    border-radius: 9px;
    padding: 7px 10px;
    font-size: 0.74rem;
    line-height: 1.35;
}

.pf-esp32emu-sim-float-history {
    max-height: none;
    min-height: 78px;
    overflow: auto;
    display: grid;
    gap: 4px;
    padding-right: 4px;
    align-content: start;
    flex: 1 1 auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(142, 184, 240, 0.75) rgba(20, 32, 49, 0.45);
}

.pf-esp32emu-sim-float-history::-webkit-scrollbar {
    width: 9px;
}

.pf-esp32emu-sim-float-history::-webkit-scrollbar-track {
    border-radius: 12px;
    background: rgba(20, 32, 49, 0.45);
}

.pf-esp32emu-sim-float-history::-webkit-scrollbar-thumb {
    border-radius: 12px;
    border: 2px solid rgba(20, 32, 49, 0.45);
    background: linear-gradient(180deg, rgba(148, 203, 255, 0.95), rgba(117, 165, 224, 0.95));
}

.pf-esp32emu-sim-float-history::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, rgba(179, 223, 255, 0.95), rgba(136, 184, 241, 0.95));
}

.pf-esp32emu-sim-float-history-item {
    border-radius: 7px;
    padding: 4px 7px;
    background: rgba(255, 255, 255, 0.06);
    color: #dde9f9;
    font-size: 0.72rem;
    line-height: 1.35;
}

.pf-esp32emu-sim-float-history-repeat {
    display: inline-block;
    margin-left: 6px;
    padding: 0 6px;
    border-radius: 999px;
    border: 1px solid rgba(179, 210, 245, 0.44);
    background: rgba(28, 46, 69, 0.6);
    color: #d9ebff;
    font-size: 0.68rem;
    font-weight: 700;
}

.pf-esp32emu-sim-float-history-item.is-warn {
    background: rgba(247, 195, 42, 0.2);
    color: #ffe7a1;
}

.pf-esp32emu-sim-float-history-item.is-error,
.pf-esp32emu-sim-float-history-item.is-critical {
    background: rgba(248, 105, 98, 0.2);
    color: #ffd2cf;
}

.pf-esp32emu-sim-float-history-item.is-behavior {
    background: rgba(98, 213, 130, 0.2);
    color: #d5ffd7;
}

.pf-esp32emu-sim-float-mini {
    display: none;
    align-items: center;
    justify-content: center;
    position: relative;
    width: 90px;
    height: 90px;
    border-radius: 50%;
    border: 2px solid #2f4766;
    background: radial-gradient(circle at 35% 28%, rgba(30, 56, 88, 0.96) 0%, rgba(18, 31, 49, 0.98) 62%, rgba(13, 23, 37, 0.99) 100%);
    color: #90a7c3;
    box-shadow: 0 8px 20px rgba(0,0,0,0.58);
    overflow: hidden;
    font-weight: 700;
    letter-spacing: 0.9px;
    text-transform: uppercase;
    transition: transform 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275), border-color 0.25s ease, box-shadow 0.25s ease, color 0.25s ease;
    cursor: pointer;
}

.pf-esp32emu-sim-float-mini:hover {
    transform: translateY(-1px) scale(1.03);
    border-color: #4e78aa;
}

.pf-esp32emu-sim-float-mini-icon {
    width: 34px;
    height: 34px;
    display: inline-flex;
    margin-bottom: 3px;
    position: relative;
    z-index: 2;
}

.pf-esp32emu-sim-float-mini-icon svg {
    width: 100%;
    height: 100%;
}

.pf-esp32emu-livesimulation-badge {
    flex-direction: column;
}

.pf-esp32emu-livesimulation-badge-pulse {
    position: absolute;
    inset: -5px;
    border-radius: 50%;
    border: 2px solid transparent;
    opacity: 0;
    pointer-events: none;
}

.pf-esp32emu-livesimulation-badge-dot {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #555;
    box-shadow: 0 0 5px #555;
    transition: all 0.25s ease;
    z-index: 3;
}

.pf-esp32emu-livesimulation-badge-icon {
    color: currentColor;
}

.pf-esp32emu-livesimulation-badge-text {
    position: relative;
    z-index: 2;
    font-size: 11px;
}

.pf-esp32emu-livesimulation-badge.is-running {
    color: #69d7a5;
    border-color: #3a9b78;
    box-shadow: 0 0 20px rgba(78, 188, 142, 0.2), 0 8px 20px rgba(0,0,0,0.58);
}

.pf-esp32emu-livesimulation-badge.is-running .pf-esp32emu-livesimulation-badge-pulse {
    border-color: #5bc79a;
    opacity: 1;
    animation: pf-esp32emu-live-badge-pulse-ring 2s infinite;
}

.pf-esp32emu-livesimulation-badge.is-running .pf-esp32emu-livesimulation-badge-dot {
    background: #d9fff0;
    box-shadow: 0 0 8px #58c595;
    animation: pf-esp32emu-live-badge-blink-dot 1s infinite alternate;
}

.pf-esp32emu-livesimulation-badge.is-paused {
    color: #e8c96a;
    border-color: #a9892e;
    box-shadow: 0 0 14px rgba(214, 174, 69, 0.18), 0 8px 20px rgba(0,0,0,0.58);
}

.pf-esp32emu-livesimulation-badge.is-paused .pf-esp32emu-livesimulation-badge-dot {
    background: #f0d98e;
    box-shadow: 0 0 6px #d4b35a;
}

.pf-esp32emu-livesimulation-badge.is-stopped {
    color: #e77d7d;
    border-color: #a24c4c;
}

.pf-esp32emu-livesimulation-badge.is-stopped .pf-esp32emu-livesimulation-badge-dot {
    background: #f29a9a;
    box-shadow: 0 0 6px rgba(216, 106, 106, 0.55);
}

@keyframes pf-esp32emu-live-badge-pulse-ring {
    0% {
        transform: scale(0.9);
        opacity: 0.85;
        border-width: 4px;
    }
    100% {
        transform: scale(1.4);
        opacity: 0;
        border-width: 0;
    }
}

@keyframes pf-esp32emu-live-badge-blink-dot {
    from {
        opacity: 0.42;
    }
    to {
        opacity: 1;
        transform: scale(1.2);
    }
}

.pf-esp32emu-sim-float.is-minimized {
    width: 90px;
    height: 90px;
    min-width: 0;
    border-radius: 50%;
    padding: 0;
    border: none;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
}

.pf-esp32emu-sim-float.is-minimized .pf-esp32emu-sim-float-mini {
    cursor: grab;
}

.pf-esp32emu-sim-float.is-minimized.is-dragging .pf-esp32emu-sim-float-mini {
    cursor: grabbing;
}

.pf-esp32emu-sim-float.is-minimized .pf-esp32emu-sim-float-head,
.pf-esp32emu-sim-float.is-minimized .pf-esp32emu-sim-float-controls,
.pf-esp32emu-sim-float.is-minimized .pf-esp32emu-sim-float-meta {
    display: none;
}

.pf-esp32emu-sim-float.is-minimized .pf-esp32emu-sim-float-resize-handle {
    display: none;
}

.pf-esp32emu-sim-float.is-minimized .pf-esp32emu-sim-float-mini {
    display: inline-flex;
}

.pf-esp32emu-placed-item.is-sim-led-on {
    filter: drop-shadow(0 0 12px rgba(255, 71, 59, 0.85));
}

.pf-esp32emu-template-doc {
    margin-top: 10px;
    border: 1px solid var(--pf-esp32emu-border);
    background: #fff;
    border-radius: 10px;
    padding: 10px;
    display: grid;
    gap: 8px;
}

.pf-esp32emu-template-doc-head {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.pf-esp32emu-template-title-name {
    display: block;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--pf-esp32emu-muted);
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pf-esp32emu-template-doc-actions {
    display: flex;
    gap: 6px;
}

.pf-esp32emu-template-doc-switches {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

.pf-esp32emu-template-doc-switch {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    padding: 6px 10px;
    border: 1px solid var(--pf-esp32emu-border);
    border-radius: 999px;
    background: #fff;
    font-size: 0.76rem;
    font-weight: 700;
    color: var(--pf-esp32emu-text);
    cursor: pointer;
}

.pf-esp32emu-template-doc-switch-main {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.pf-esp32emu-template-doc-switch-input {
    width: 14px;
    height: 14px;
    margin: 0;
    accent-color: var(--pf-esp32emu-accent);
}

.pf-esp32emu-template-doc-switch-label {
    line-height: 1;
}

.pf-esp32emu-template-doc-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    padding: 0;
    border-radius: 999px;
    border: 1px solid var(--pf-esp32emu-border);
    background: #fff;
    color: var(--pf-esp32emu-accent-strong);
    flex-shrink: 0;
    cursor: pointer;
    transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease, color 0.18s ease;
}

.pf-esp32emu-template-doc-icon-btn:hover {
    transform: translateY(-1px);
    border-color: var(--pf-esp32emu-accent);
    background: var(--pf-esp32emu-accent-soft);
}

.pf-esp32emu-template-doc-icon-btn svg {
    width: 14px;
    height: 14px;
}

.pf-esp32emu-template-doc-block {
    display: grid;
    gap: 6px;
    margin-bottom: 10px;
}

.pf-esp32emu-template-doc-block[hidden] {
    display: none;
}

.pf-esp32emu-template-doc-label {
    font-size: 0.75rem;
    color: var(--pf-esp32emu-muted);
    font-weight: 700;
}

.pf-esp32emu-template-doc-text {
    width: 100%;
    min-height: 145px;
    border: 1px solid var(--pf-esp32emu-border);
    border-radius: 8px;
    padding: 8px;
    resize: vertical;
    background: #fcfdff;
    color: #1f2d40;
    font-size: 0.74rem;
    line-height: 1.4;
    font-family: Consolas, Monaco, monospace;
}

.pf-esp32emu-template-doc-text.is-notes {
    min-height: 110px;
}

.pf-esp32emu-template-section {
    margin-top: 14px;
    padding: 16px;
    border: 1px solid var(--pf-esp32emu-border);
    border-radius: 16px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.9) 0%, rgba(247, 249, 252, 0.98) 100%);
    box-shadow: 0 12px 28px rgba(18, 32, 52, 0.06);
}

.pf-esp32emu-template-section-head {
    display: grid;
    gap: 6px;
    margin-bottom: 14px;
}

.pf-esp32emu-template-section-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.88rem;
    font-weight: 800;
    color: var(--pf-esp32emu-text);
}

.pf-esp32emu-template-section-copy {
    font-size: 0.76rem;
    color: var(--pf-esp32emu-muted);
}

.pf-esp32emu-template-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.pf-esp32emu-template-card {
    --pf-esp32emu-template-delay: 0ms;
    position: relative;
    display: grid;
    grid-template-columns: 124px 1fr;
    gap: 14px;
    align-items: stretch;
    width: 100%;
    min-height: 184px;
    padding: 16px;
    border: 1px solid var(--pf-esp32emu-border);
    border-radius: 18px;
    background: linear-gradient(180deg, #ffffff 0%, #fafcff 100%);
    color: var(--pf-esp32emu-text);
    cursor: pointer;
    text-align: left;
    overflow: hidden;
    box-shadow: 0 8px 18px rgba(18, 32, 52, 0.06);
    transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease, background 0.22s ease;
    animation: pf-esp32emu-template-card-enter 0.55s ease both;
    animation-delay: var(--pf-esp32emu-template-delay);
}

.pf-esp32emu-template-card:nth-child(1) { --pf-esp32emu-template-delay: 0ms; }
.pf-esp32emu-template-card:nth-child(2) { --pf-esp32emu-template-delay: 40ms; }
.pf-esp32emu-template-card:nth-child(3) { --pf-esp32emu-template-delay: 80ms; }
.pf-esp32emu-template-card:nth-child(4) { --pf-esp32emu-template-delay: 120ms; }
.pf-esp32emu-template-card:nth-child(5) { --pf-esp32emu-template-delay: 160ms; }
.pf-esp32emu-template-card:nth-child(6) { --pf-esp32emu-template-delay: 200ms; }

.pf-esp32emu-template-card:hover {
    transform: translateY(-4px);
    border-color: var(--pf-esp32emu-accent);
    box-shadow: 0 18px 34px rgba(18, 32, 52, 0.13);
}

.pf-esp32emu-template-card:focus-visible {
    outline: 3px solid rgba(191, 53, 41, 0.22);
    outline-offset: 2px;
}

.pf-esp32emu-template-card.is-active {
    border-color: var(--pf-esp32emu-accent);
    background: linear-gradient(145deg, #ffffff 0%, #fff7f6 100%);
    box-shadow: 0 0 0 4px rgba(191, 53, 41, 0.10), 0 18px 36px rgba(191, 53, 41, 0.12);
}

.pf-esp32emu-template-card.is-active::after {
    content: 'AKTIV';
    position: absolute;
    top: 14px;
    left: 14px;
    right: auto;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--pf-esp32emu-accent);
    color: #fff;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    z-index: 2;
}

.pf-esp32emu-template-card-visual {
    position: relative;
    display: grid;
    place-items: center;
    min-height: 152px;
    border-radius: 16px;
    background: linear-gradient(180deg, rgba(245, 247, 250, 1) 0%, rgba(236, 241, 247, 1) 100%);
    color: var(--pf-esp32emu-accent-strong);
    overflow: hidden;
}

.pf-esp32emu-template-card-visual::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.75), rgba(255, 255, 255, 0) 50%);
    opacity: 0.85;
}

.pf-esp32emu-template-card:hover .pf-esp32emu-template-card-visual {
    background: linear-gradient(180deg, #eef6ff 0%, #e2eefb 100%);
    transform: scale(1.01);
}

.pf-esp32emu-template-card.is-active .pf-esp32emu-template-card-visual {
    background: linear-gradient(180deg, #fff1ef 0%, #ffe4df 100%);
    animation: pf-esp32emu-template-pulse 2.6s ease-in-out infinite;
}

.pf-esp32emu-template-card-visual svg {
    position: relative;
    width: 76px;
    height: 76px;
    fill: currentColor;
    stroke: currentColor;
    z-index: 1;
    filter: drop-shadow(0 8px 14px rgba(18, 32, 52, 0.14));
    transition: transform 0.22s ease;
}

.pf-esp32emu-template-card:hover .pf-esp32emu-template-card-visual svg {
    transform: scale(1.04) rotate(2deg);
}

.pf-esp32emu-template-card-body {
    display: grid;
    align-content: start;
    gap: 10px;
}

.pf-esp32emu-template-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.pf-esp32emu-template-card-title-wrap {
    display: grid;
    gap: 3px;
}

.pf-esp32emu-template-card-kicker {
    font-size: 0.70rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--pf-esp32emu-muted);
}

.pf-esp32emu-template-card-title {
    font-size: 1.18rem;
    font-weight: 800;
    line-height: 1.15;
    color: var(--pf-esp32emu-text);
}

.pf-esp32emu-template-card-badges {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.pf-esp32emu-template-card-badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 4px 8px;
    font-size: 0.66rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #fff;
    background: linear-gradient(145deg, var(--pf-esp32emu-accent), var(--pf-esp32emu-accent-strong));
}

/* HOT badge - green background variant */
.pf-esp32emu-template-card-badge-hot {
    background: linear-gradient(145deg, #28a745, #218838);
    color: #fff;
}

/* Dark theme override for HOT badge */
#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-template-card-badge-hot {
    background: linear-gradient(145deg, #2fb84b, #1f8f33);
}

.pf-esp32emu-template-card-badge.is-secondary {
    background: #f0f4f9;
    color: var(--pf-esp32emu-muted);
    border: 1px solid var(--pf-esp32emu-border);
}

.pf-esp32emu-template-card-desc {
    font-size: 0.84rem;
    line-height: 1.55;
    color: var(--pf-esp32emu-muted);
}

.pf-esp32emu-template-card-tags,
.pf-esp32emu-template-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.pf-esp32emu-template-card-tag,
.pf-esp32emu-template-card-meta-item {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 4px 8px;
    font-size: 0.70rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    border: 1px solid var(--pf-esp32emu-border);
    background: #fff;
    color: var(--pf-esp32emu-text);
}

@media (max-width: 1320px) {
    .pf-esp32emu-template-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 860px) {
    .pf-esp32emu-template-grid {
        grid-template-columns: 1fr;
    }

    .pf-esp32emu-template-card {
        grid-template-columns: 104px 1fr;
        min-height: 168px;
    }

    .pf-esp32emu-template-card-visual {
        min-height: 136px;
    }
}

@keyframes pf-esp32emu-template-card-enter {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.985);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes pf-esp32emu-template-pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(191, 53, 41, 0.16);
    }
    50% {
        box-shadow: 0 0 0 12px rgba(191, 53, 41, 0);
    }
}

.pf-esp32emu-to-top {
    position: fixed;
    right: 18px;
    bottom: 20px;
    z-index: 80;
    border: 1px solid var(--pf-esp32emu-accent);
    background: var(--pf-esp32emu-accent);
    color: #fff;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
    padding: 8px 12px;
    box-shadow: 0 8px 24px rgba(191, 53, 41, 0.26);
    opacity: 0;
    transform: translateY(12px);
    pointer-events: none;
    transition: 0.2s ease;
}

.pf-esp32emu-to-top.is-visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.pf-esp32emu-footer {
    margin: 10px 12px 12px;
    padding: 10px 12px;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 8px;
    font-size: 0.74rem;
    color: var(--pf-esp32emu-muted);
    border-radius: 0 0 var(--pf-esp32emu-radius) var(--pf-esp32emu-radius);
    overflow: hidden;
    transition: opacity 0.2s ease, max-height 0.2s ease, padding 0.2s ease;
}

.pf-esp32emu-footer-left,
.pf-esp32emu-footer-right,
.pf-esp32emu-footer-center {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 24px;
}

.pf-esp32emu-footer-center {
    justify-content: center;
}

.pf-esp32emu-footer-right {
    justify-self: end;
}

.pf-esp32emu-footer-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

.pf-esp32emu-footer-icon svg {
    width: 100%;
    height: 100%;
}

.pf-esp32emu-footer-fx-toggle {
    width: 34px;
    height: 24px;
    border-radius: 999px;
    border: 1px solid var(--pf-esp32emu-border);
    background: #fff;
    color: var(--pf-esp32emu-accent-strong);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.92), 0 5px 12px rgba(18, 32, 52, 0.08);
}

.pf-esp32emu-footer-fx-toggle svg {
    width: 14px;
    height: 14px;
}

.pf-esp32emu-footer-fx-toggle .pf-esp32emu-footer-icon-off {
    display: none;
}

#pf-esp32emu-app.is-footer-fx-off .pf-esp32emu-footer-fx-toggle .pf-esp32emu-footer-icon-on {
    display: none;
}

#pf-esp32emu-app.is-footer-fx-off .pf-esp32emu-footer-fx-toggle .pf-esp32emu-footer-icon-off {
    display: inline-flex;
}

#pf-esp32emu-app:not(.is-footer-fx-off) .pf-esp32emu-footer {
    box-shadow: inset 0 0 0 1px rgba(216, 75, 62, 0.1), 0 0 22px rgba(216, 75, 62, 0.14);
}

#pf-esp32emu-app.is-footer-fx-off .pf-esp32emu-footer {
    box-shadow: none;
}

#pf-esp32emu-app.pf-esp32emu-app.overlay-mode .pf-esp32emu-header,
#pf-esp32emu-app.pf-esp32emu-app.overlay-mode .pf-esp32emu-footer {
    color: rgba(255, 255, 255, 0.96);
    background: linear-gradient(135deg, #0e7f8d 0%, #2957b7 48%, #11a7c4 100%);
    border-color: rgba(255, 255, 255, 0.22);
}

#pf-esp32emu-app.pf-esp32emu-app.overlay-mode .pf-esp32emu-header {
    box-shadow: none;
}

#pf-esp32emu-app.pf-esp32emu-app.overlay-mode .pf-esp32emu-footer {
    margin: 0;
    padding: 8px 18px;
    border-top: 1px solid rgba(255, 255, 255, 0.22);
    box-shadow: 0 -8px 22px rgba(22, 82, 164, 0.24);
    border-radius: 0 0 var(--pf-esp32emu-radius) var(--pf-esp32emu-radius);
}

#pf-esp32emu-app.pf-esp32emu-app.overlay-mode .pf-esp32emu-title,
#pf-esp32emu-app.pf-esp32emu-app.overlay-mode .pf-esp32emu-meta,
#pf-esp32emu-app.pf-esp32emu-app.overlay-mode .pf-esp32emu-user-name,
#pf-esp32emu-app.pf-esp32emu-app.overlay-mode .pf-esp32emu-footer-module,
#pf-esp32emu-app.pf-esp32emu-app.overlay-mode .pf-esp32emu-footer-meta,
#pf-esp32emu-app.pf-esp32emu-app.overlay-mode .pf-esp32emu-footer-runtime {
    color: rgba(255, 255, 255, 0.92);
}

#pf-esp32emu-app.pf-esp32emu-app.overlay-mode .pf-esp32emu-drag-handle,
#pf-esp32emu-app.pf-esp32emu-app.overlay-mode .pf-esp32emu-icon-wrapper,
#pf-esp32emu-app.pf-esp32emu-app.overlay-mode .pf-esp32emu-user-pill,
#pf-esp32emu-app.pf-esp32emu-app.overlay-mode .pf-esp32emu-footer-fx-toggle {
    border-color: rgba(255, 255, 255, 0.28);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.22) 0%, rgba(255, 255, 255, 0.1) 100%);
    color: #fff;
}

#pf-esp32emu-app.pf-esp32emu-app.overlay-mode .pf-esp32emu-btn-dashboard {
    border-color: rgba(255, 255, 255, 0.28);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.22) 0%, rgba(255, 255, 255, 0.1) 100%);
    color: #fff;
}

#pf-esp32emu-app[data-pf-esp32emu-workspace-embed="1"] {
    min-height: 100%;
    grid-template-rows: 1fr;
}

#pf-esp32emu-app[data-pf-esp32emu-workspace-embed="1"] .pf-esp32emu-header,
#pf-esp32emu-app[data-pf-esp32emu-workspace-embed="1"] .pf-esp32emu-footer,
#pf-esp32emu-app[data-pf-esp32emu-workspace-embed="1"] .pf-esp32emu-panel-reopen-bar,
#pf-esp32emu-app[data-pf-esp32emu-workspace-embed="1"] #pf-esp32emu-monitor-close,
#pf-esp32emu-app[data-pf-esp32emu-workspace-embed="1"] #pf-esp32emu-monitor-reopen {
    display: none !important;
}

#pf-esp32emu-app[data-pf-esp32emu-workspace-embed="1"] .pf-esp32emu-layout {
    min-height: 100%;
    padding: 8px;
}

#pf-esp32emu-app.pf-esp32emu-app.overlay-mode .pf-esp32emu-btn-dashboard:hover,
#pf-esp32emu-app.pf-esp32emu-app.overlay-mode .pf-esp32emu-user-pill:hover,
#pf-esp32emu-app.pf-esp32emu-app.overlay-mode .pf-esp32emu-icon-wrapper:hover,
#pf-esp32emu-app.pf-esp32emu-app.overlay-mode .pf-esp32emu-footer-fx-toggle:hover {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.34) 0%, rgba(255, 255, 255, 0.16) 100%);
}

#pf-esp32emu-app.pf-esp32emu-app.overlay-mode .pf-esp32emu-footer-icon {
    color: #fff;
}

@media (max-width: 1440px) {
    .pf-esp32emu-layout {
        --pf-esp32emu-sidebar-width: 220px;
        --pf-esp32emu-monitor-width: 250px;
        grid-template-columns: var(--pf-esp32emu-sidebar-width) 1fr var(--pf-esp32emu-monitor-width);
    }
}

@media (max-width: 900px) {
    .pf-esp32emu-layout {
        grid-template-columns: 1fr;
    }

    .pf-esp32emu-monitor-resizer {
        display: none;
    }

    .pf-esp32emu-sidebar,
    .pf-esp32emu-monitor-panel {
        min-height: 220px;
    }
}

@media (max-width: 860px) {
    .pf-esp32emu-header {
        flex-wrap: nowrap;
        gap: 6px;
        padding: 8px;
    }

    .pf-esp32emu-header-left,
    .pf-esp32emu-header-right {
        gap: 6px;
    }

    .pf-esp32emu-header-compact-logo {
        display: none;
    }

    .pf-esp32emu-title-section,
    .pf-esp32emu-user-name,
    .pf-esp32emu-dashboard-label,
    .pf-esp32emu-footer-meta,
    .pf-esp32emu-footer-module,
    .pf-esp32emu-footer-runtime {
        display: none;
    }

    .pf-esp32emu-user-pill,
    .pf-esp32emu-btn-dashboard {
        min-width: 40px;
        height: 40px;
        padding: 0;
        justify-content: center;
    }

    .pf-esp32emu-btn-dashboard .pf-esp32emu-dashboard-logo {
        width: 24px;
        height: 24px;
    }

    .pf-esp32emu-dashboard-submenu {
        right: -2px;
        min-width: 190px;
    }

    .pf-esp32emu-dashboard-submenu-item {
        font-size: 0.75rem;
    }

    #pf-esp32emu-app.is-mobile-shell-collapsed .pf-esp32emu-header {
        min-height: 0;
        height: 0;
        padding: 0;
        border: 0;
        box-shadow: none;
        background: transparent;
        overflow: visible;
        opacity: 1;
        pointer-events: auto;
    }

    #pf-esp32emu-app.is-mobile-shell-collapsed .pf-esp32emu-header-left {
        display: none;
    }

    #pf-esp32emu-app.is-mobile-shell-collapsed .pf-esp32emu-header-right {
        display: inline-flex;
        position: fixed;
        top: 10px;
        right: 10px;
        left: auto;
        z-index: 240;
        margin-left: 0;
        gap: 0;
        pointer-events: auto;
    }

    #pf-esp32emu-app.is-mobile-shell-collapsed .pf-esp32emu-header-right > :not(.pf-esp32emu-dashboard-menu) {
        display: none !important;
    }

    #pf-esp32emu-app.is-mobile-shell-collapsed .pf-esp32emu-dashboard-menu {
        display: inline-flex;
    }

    #pf-esp32emu-app.is-mobile-shell-collapsed .pf-esp32emu-btn-dashboard {
        width: 44px;
        height: 44px;
        min-width: 44px;
        border-radius: 999px;
        overflow: hidden;
        box-shadow: 0 6px 14px rgba(8, 17, 31, 0.25);
    }

    #pf-esp32emu-app.is-mobile-shell-collapsed .pf-esp32emu-footer {
        display: none;
    }

    #pf-esp32emu-app.is-mobile-shell-collapsed .pf-esp32emu-to-top {
        bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    }

    .pf-esp32emu-info-layout {
        grid-template-columns: 1fr;
    }

    .pf-esp32emu-footer {
        grid-template-columns: auto auto;
        justify-content: space-between;
    }

    .pf-esp32emu-footer-left,
    .pf-esp32emu-footer-right,
    .pf-esp32emu-footer-center {
        min-height: 0;
    }

    .pf-esp32emu-workspace-controls {
        margin: 0 0 10px 12px;
        max-width: calc(100% - 20px);
        width: calc(100% - 20px);
    }

    .pf-esp32emu-workspace-controls .pf-esp32emu-btn {
        flex: 1 1 calc(50% - 7px);
    }

    .pf-esp32emu-breadboard {
        left: 0;
        top: 0;
        margin: 12px 1em 1em 12px;
    }

    .pf-esp32emu-sim-float {
        left: 50%;
        right: auto;
        bottom: 10px;
        top: auto;
        transform: translateX(-50%);
        width: auto;
        min-width: 0;
        min-height: 0;
        max-height: calc(100vh - 14px);
        padding: 10px;
    }

    .pf-esp32emu-sim-float.is-floating-placed {
        transform: none;
    }

    .pf-esp32emu-sim-float-controls .pf-esp32emu-btn {
        flex: 1 1 calc(50% - 4px);
        min-width: 138px;
    }

    .pf-esp32emu-sim-float-drag-hint,
    .pf-esp32emu-sim-float-resize-handle {
        display: none;
    }
}

#pf-esp32emu-app.pf-esp32emu-theme-dark {
    --pf-esp32emu-bg: #171d25;
    --pf-esp32emu-panel: #202936;
    --pf-esp32emu-panel-soft: #19212e;
    --pf-esp32emu-border: #304155;
    --pf-esp32emu-text: #dbe7f4;
    --pf-esp32emu-muted: #8ca2bc;
    --pf-esp32emu-accent-soft: #48241f;
    --pf-esp32emu-shadow: 0 10px 28px rgba(0, 0, 0, 0.3);
}

#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-btn:hover {
    background: #273241;
    color: #ffffff;
}

#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-dashboard-submenu-item {
    background: #1f2835;
    border-color: #3b4b61;
    color: #dbe7f4;
}

#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-dashboard-submenu {
    border-color: #3b4b61;
    background: rgba(25, 33, 46, 0.98);
}

#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-dashboard-submenu::before {
    border-bottom-color: #3b4b61;
}

#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-dashboard-submenu::after {
    border-bottom-color: rgba(25, 33, 46, 0.98);
}

#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-dashboard-submenu-item:hover {
    background: #2a3647;
    border-color: #4a607c;
}

#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-sim-float {
    border-color: rgba(102, 128, 156, 0.5);
    background: rgba(10, 14, 22, 0.94);
    color: #d7e5f5;
}

#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-workspace {
    background: linear-gradient(180deg, #1a232f 0%, #131a23 100%);
}

#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-body {
    scrollbar-color: #4d627a #131c29;
}

#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-body::-webkit-scrollbar-track {
    background: #131c29;
}

#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-body::-webkit-scrollbar-thumb {
    background: #4d627a;
    border-color: #131c29;
}

#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-workspace,
#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-console,
#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-template-doc-text,
#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-sidebar,
#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-monitor-panel {
    scrollbar-color: #4d627a #131c29;
}

/* ── Panel close / reopen ─────────────────────────────────────── */

/* Panel header: title + close button in a row */
.pf-esp32emu-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    margin-bottom: 8px;
}

.pf-esp32emu-panel-header-title {
    font-size: 0.74rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--pf-esp32emu-muted);
    font-weight: 700;
}

/* Monitor header: push close button to the right */
.pf-esp32emu-monitor-header {
    justify-content: flex-start;
}

/* Template-doc-head: put close button on the right */
.pf-esp32emu-template-doc-head {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
}

/* The × close button used in sidebar, monitor, and template-doc */
.pf-esp32emu-panel-close {
    flex-shrink: 0;
    margin-left: auto;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1px solid var(--pf-esp32emu-border);
    background: transparent;
    color: var(--pf-esp32emu-muted);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.12s ease, color 0.12s ease;
}

.pf-esp32emu-panel-close:hover {
    background: #ffeaea;
    color: #c0392b;
    border-color: #e5b0ab;
}

/* Keep sidebar/monitor in grid flow; collapse them instead of display:none.
   Otherwise grid auto-placement can move workspace into the 0px column. */
.pf-esp32emu-sidebar.is-panel-hidden,
.pf-esp32emu-monitor-panel.is-panel-hidden {
    width: 0;
    min-width: 0;
    max-width: 0;
    padding: 0;
    border-width: 0;
    opacity: 0;
    transform: scale(0.98);
    pointer-events: none;
    overflow: hidden;
}

.pf-esp32emu-template-doc.is-panel-hidden {
    display: none;
}

.pf-esp32emu-layout.is-sidebar-hidden {
    grid-template-columns: 0px 1fr var(--pf-esp32emu-monitor-width);
    gap: 4px 10px;
}

.pf-esp32emu-layout.is-monitor-hidden {
    grid-template-columns: var(--pf-esp32emu-sidebar-width) 1fr 0px;
    gap: 10px 4px;
}

.pf-esp32emu-layout.is-sidebar-hidden.is-monitor-hidden {
    grid-template-columns: 0px 1fr 0px;
    gap: 4px;
}

/* Reopen bar: sits below the layout section, shows when any panel is closed */
.pf-esp32emu-panel-reopen-bar {
    display: flex;
    gap: 8px;
    padding: 4px 0 0;
}

.pf-esp32emu-panel-reopen {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 8px;
    border: 1px solid var(--pf-esp32emu-border);
    background: var(--pf-esp32emu-panel-soft);
    color: var(--pf-esp32emu-text);
    font-size: 0.78rem;
    cursor: pointer;
    transition: background 0.12s ease;
}

.pf-esp32emu-panel-reopen:hover {
    background: var(--pf-esp32emu-panel);
}

/* Dark theme overrides */
#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-panel-close:hover {
    background: #3d1a1a;
    color: #ff8080;
    border-color: #6b3535;
}

#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-workspace::-webkit-scrollbar-track,
#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-console::-webkit-scrollbar-track,
#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-template-doc-text::-webkit-scrollbar-track,
#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-sidebar::-webkit-scrollbar-track,
#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-monitor-panel::-webkit-scrollbar-track {
    background: #131c29;
}

#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-workspace::-webkit-scrollbar-thumb,
#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-console::-webkit-scrollbar-thumb,
#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-template-doc-text::-webkit-scrollbar-thumb,
#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-sidebar::-webkit-scrollbar-thumb,
#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-monitor-panel::-webkit-scrollbar-thumb {
    background: #4d627a;
    border-color: #131c29;
}

#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-wire-color-status,
#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-res-opt,
#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-comp-item,
#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-template-doc {
    background: #1f2835;
    border-color: #3b4b61;
    color: #dbe7f4;
}

#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-template-section {
    background: linear-gradient(180deg, rgba(20, 26, 36, 0.96) 0%, rgba(25, 32, 43, 0.98) 100%);
}

#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-template-card {
    background: linear-gradient(180deg, #1f2835 0%, #18212d 100%);
    border-color: #3b4b61;
    color: #dbe7f4;
}

#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-template-card:hover {
    background: linear-gradient(180deg, #243244 0%, #1b2533 100%);
    border-color: #4a607c;
}

#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-template-card-visual {
    background: linear-gradient(180deg, #283548 0%, #1d2835 100%);
    color: #9ec2ff;
}

#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-template-card.is-active {
    background: linear-gradient(145deg, #211b22 0%, #2a1d1d 100%);
    box-shadow: 0 0 0 4px rgba(191, 53, 41, 0.16), 0 18px 36px rgba(0, 0, 0, 0.18);
}

#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-template-card-title,
#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-template-section-label,
#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-template-card-tag,
#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-template-card-meta-item {
    color: #dbe7f4;
}

#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-template-card-kicker,
#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-template-section-copy,
#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-template-card-desc {
    color: #9cb2ca;
}

#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-template-card-badge.is-secondary {
    background: #243244;
    border-color: #3b4b61;
    color: #c9d7e8;
}

#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-template-doc-label,
#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-wire-color-label,
#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-info-note,
#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-user-name {
    color: #9cb2ca;
}

#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-template-doc-text {
    background: #141c27;
    border-color: #3b4b61;
    color: #dbe7f4;
}

#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-breadboard-wrapper {
    background: #1a232f;
    border-color: #34485d;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-grid-master {
    background: #18222e;
    border-color: #2f4054;
}

#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-grid-master-secondary {
    background: #15202b;
    border-color: #2b3d50;
}

#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-cell-hole {
    border-bottom-color: #2a384a;
}

#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-pin-ghost {
    background: #71859a;
    box-shadow: inset 1px 1px 2px rgba(0, 0, 0, 0.56);
}

#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-cell-number,
#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-cell-label-row,
#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-cell-label-pwr {
    color: #8ea6bf;
}

#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-cell-label-row,
#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-cell-label-pwr,
#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-cell-number,
#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-cell-number-spacer {
    background: #18222e;
}

#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-cell-rift {
    background: #121a24;
    border-top-color: #2a384a;
    border-bottom-color: #2a384a;
}

#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-breadboard-signature {
    color: #7e96b1;
}

#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-color-modal > .pf-esp32emu-modal-card,
#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-confirm-modal > .pf-esp32emu-modal-card {
    background: #1f2835;
    color: #dbe7f4;
}

#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-choice-btn {
    background: #1a2330;
    border-color: #324659;
    color: #dbe7f4;
}

#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-choice-btn:hover {
    background: #233043;
    border-color: #4d6580;
}

#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-choice-meta,
#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-choice-usage,
#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-resistor-help-summary,
#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-resistor-help-example,
#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-resistor-help-card {
    color: #c8d8e8;
}

#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-resistor-help {
    background: #1e2b37;
    border-color: #314456;
}

#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-resistor-help-card {
    background: #243442;
    border-color: #314456;
}

#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-inline-info {
    border-color: #4e617d;
    background: #253247;
    color: #d2e0f4;
}

#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-sim-hint {
    border-color: #3c4f69;
    background: #1f2a39;
    color: #b7c9df;
}

#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-sim-hint.is-warning {
    border-color: #6d3f3a;
    background: #3a2322;
    color: #f0b8b2;
}

#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-sim-hint.is-ok {
    border-color: #355b45;
    background: #1e3428;
    color: #a8ddbb;
}

#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-sim-hint.is-live {
    border-color: #3a5674;
    background: #1e3046;
    color: #add1f2;
}

#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-color-modal .pf-esp32emu-modal-footer,
#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-confirm-modal .pf-esp32emu-modal-footer {
    border-top-color: #2d3e52;
    background: #19222e;
}

#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-confirm-copy {
    color: #9eb2cc;
}

/* ===== Simulator Panels: E-Ink, WiFi, PFWS ===== */

.pf-esp32emu-simulator-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
    background: var(--pf-esp32emu-panel);
    border: 1px solid var(--pf-esp32emu-border);
    border-radius: var(--pf-esp32emu-radius);
    box-shadow: var(--pf-esp32emu-shadow);
    min-width: 280px;
    flex: 1 1 auto;
}

.pf-esp32emu-panel-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--pf-esp32emu-text);
    margin-bottom: 8px;
}

/* E-Ink Display Simulator */
.pf-esp32emu-eink-panel {
    grid-column: auto;
}

.pf-esp32emu-eink-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.pf-esp32emu-eink-display {
    width: 100%;
    aspect-ratio: 4 / 3;
    background: linear-gradient(135deg, #f5f5f0 0%, #e8e8e0 100%);
    border: 2px solid #333;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.1);
}

.pf-esp32emu-eink-content {
    font-size: 12px;
    color: #333;
    text-align: center;
    font-family: monospace;
    white-space: pre-wrap;
    word-break: break-all;
}

.pf-esp32emu-eink-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pf-esp32emu-control-group {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.pf-esp32emu-control-input {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--pf-esp32emu-cyan);
}

.pf-esp32emu-control-label {
    font-size: 13px;
    color: var(--pf-esp32emu-text);
    flex: 1;
}

.pf-esp32emu-btn-small {
    padding: 8px 12px;
    font-size: 12px;
    background: var(--pf-esp32emu-panel-soft);
    border: 1px solid var(--pf-esp32emu-border);
    color: var(--pf-esp32emu-text);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.pf-esp32emu-btn-small:hover {
    background: var(--pf-esp32emu-border);
}

/* WiFi Module Status Panel */
.pf-esp32emu-wifi-panel {
    grid-column: auto;
}

.pf-esp32emu-wifi-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.pf-esp32emu-wifi-status {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--pf-esp32emu-panel-soft);
    border-radius: 8px;
}

.pf-esp32emu-wifi-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #999;
    animation: pulse 2s infinite;
}

.pf-esp32emu-wifi-indicator.connected {
    background: #27ae60;
}

.pf-esp32emu-wifi-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--pf-esp32emu-text);
}

.pf-esp32emu-wifi-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 12px;
}

.pf-esp32emu-wifi-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px;
    border-bottom: 1px solid var(--pf-esp32emu-border);
}

.pf-esp32emu-wifi-item:last-child {
    border-bottom: none;
}

.pf-esp32emu-wifi-key {
    color: var(--pf-esp32emu-muted);
    font-weight: 500;
}

.pf-esp32emu-wifi-value {
    color: var(--pf-esp32emu-text);
    font-family: monospace;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* PFWS API Panel */
.pf-esp32emu-pfws-panel {
    grid-column: auto;
}

.pf-esp32emu-pfws-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.pf-esp32emu-pfws-status {
    padding: 12px;
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: white;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
}

.pf-esp32emu-pfws-status.online {
    background: linear-gradient(135deg, #27ae60, #229954);
}

.pf-esp32emu-pfws-requests {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 12px;
}

.pf-esp32emu-request-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    background: var(--pf-esp32emu-panel-soft);
    border-radius: 4px;
}

.pf-esp32emu-request-method {
    min-width: 40px;
    font-weight: 600;
    font-size: 11px;
    padding: 3px 6px;
    background: var(--pf-esp32emu-cyan);
    color: white;
    border-radius: 3px;
    text-align: center;
}

.pf-esp32emu-request-path {
    font-family: monospace;
    color: var(--pf-esp32emu-text);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}


/* Simulator Panels Layout */
#pf-esp32emu-app {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
    min-height: 100vh;
}

#pf-esp32emu-app > section:last-of-type {
    grid-column: 1;
    grid-row: 4;
}

.pf-esp32emu-simulator-panel {
    grid-column: 1;
}

.pf-esp32emu-monitor-panel {
    grid-column: auto;
}

@supports (display: grid) {
    #pf-esp32emu-app > *:not(.pf-esp32emu-module):not(.pf-esp32emu-header):not(.pf-esp32emu-footer):not(:last-of-type):not(#pf-esp32emu-tooltip):not(#pf-esp32emu-component-menu):not(#pf-esp32emu-wire-menu):not(.pf-esp32emu-color-modal):not(.pf-esp32emu-confirm-modal) {
        display: grid;
        grid-auto-flow: column;
        grid-auto-columns: minmax(280px, 1fr);
        gap: 16px;
        padding: 16px;
        overflow-x: auto;
    }
}

/* Overlay Visual Upgrade (ESP32emu-only, no PFWS dependencies) */
.pf-esp32emu-color-modal {
    --pf-esp32emu-overlay-surface: #ffffff;
    --pf-esp32emu-overlay-panel: #f4f7fc;
    --pf-esp32emu-overlay-input: #ffffff;
    --pf-esp32emu-overlay-border: #d4ddea;
    --pf-esp32emu-overlay-text: #1f2f45;
    --pf-esp32emu-overlay-muted: #60758f;
    --pf-esp32emu-overlay-accent: #1d88b7;
    --pf-esp32emu-overlay-accent-soft: rgba(29, 136, 183, 0.12);
    --pf-esp32emu-overlay-glow: 0 0 0 2px rgba(29, 136, 183, 0.16), 0 10px 20px rgba(29, 136, 183, 0.2);
    --pf-esp32emu-overlay-preview-bg: #111923;
    --pf-esp32emu-overlay-preview-text: #79ffd2;
    --pf-esp32emu-overlay-svg-filter: none;
    background: radial-gradient(circle at 15% 10%, rgba(84, 152, 199, 0.2), transparent 46%), rgba(8, 14, 22, 0.6);
}

#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-color-modal,
#pf-esp32emu-app.is-dark-theme .pf-esp32emu-color-modal {
    --pf-esp32emu-overlay-surface: #1b2532;
    --pf-esp32emu-overlay-panel: #111a24;
    --pf-esp32emu-overlay-input: #0f1720;
    --pf-esp32emu-overlay-border: #34475d;
    --pf-esp32emu-overlay-text: #d8e4f2;
    --pf-esp32emu-overlay-muted: #98acc3;
    --pf-esp32emu-overlay-accent: #49c6f8;
    --pf-esp32emu-overlay-accent-soft: rgba(73, 198, 248, 0.18);
    --pf-esp32emu-overlay-glow: 0 0 0 2px rgba(73, 198, 248, 0.28), 0 12px 24px rgba(10, 24, 38, 0.5);
    --pf-esp32emu-overlay-preview-bg: #081018;
    --pf-esp32emu-overlay-preview-text: #7df9cc;
    --pf-esp32emu-overlay-svg-filter: drop-shadow(0 5px 8px rgba(0, 0, 0, 0.35));
}

.pf-esp32emu-color-modal > .pf-esp32emu-modal-card {
    background: linear-gradient(160deg, var(--pf-esp32emu-overlay-surface), color-mix(in srgb, var(--pf-esp32emu-overlay-surface) 84%, var(--pf-esp32emu-overlay-panel) 16%));
    border: 1px solid var(--pf-esp32emu-overlay-border);
    box-shadow: 0 24px 60px rgba(12, 20, 32, 0.28);
    transform: translateY(12px) scale(0.985);
    opacity: 0;
    transition: transform 0.24s ease, opacity 0.24s ease;
}

.pf-esp32emu-color-modal.is-open > .pf-esp32emu-modal-card {
    transform: translateY(0) scale(1);
    opacity: 1;
    animation: pf-esp32emu-overlay-card-in 0.34s cubic-bezier(0.22, 0.9, 0.35, 1);
}

.pf-esp32emu-color-modal .pf-esp32emu-modal-header {
    background: linear-gradient(135deg, #1b2f47 0%, #2f597f 100%);
}

#pf-esp32emu-app.pf-esp32emu-theme-dark .pf-esp32emu-color-modal .pf-esp32emu-modal-header,
#pf-esp32emu-app.is-dark-theme .pf-esp32emu-color-modal .pf-esp32emu-modal-header {
    background: linear-gradient(135deg, #10253a 0%, #224d71 100%);
}

.pf-esp32emu-color-modal > .pf-esp32emu-modal-card.is-help-layout .pf-esp32emu-modal-body {
    display: grid;
    grid-template-columns: minmax(240px, 34%) minmax(0, 1fr);
    align-items: start;
    gap: 14px;
}

.pf-esp32emu-color-modal > .pf-esp32emu-modal-card.is-wire-mode .pf-esp32emu-modal-body {
    display: block;
}

.pf-esp32emu-color-modal-help {
    margin: 0;
    position: sticky;
    top: 0;
    align-self: start;
}

.pf-esp32emu-color-modal .pf-esp32emu-resistor-help {
    background: linear-gradient(160deg, var(--pf-esp32emu-overlay-panel), color-mix(in srgb, var(--pf-esp32emu-overlay-panel) 86%, #ffffff 14%));
    border-color: var(--pf-esp32emu-overlay-border);
    color: var(--pf-esp32emu-overlay-text);
}

.pf-esp32emu-color-modal .pf-esp32emu-resistor-help-summary,
.pf-esp32emu-color-modal .pf-esp32emu-resistor-help-example {
    color: var(--pf-esp32emu-overlay-muted);
}

.pf-esp32emu-color-modal .pf-esp32emu-resistor-help-card {
    background: color-mix(in srgb, var(--pf-esp32emu-overlay-surface) 78%, var(--pf-esp32emu-overlay-panel) 22%);
    border-color: var(--pf-esp32emu-overlay-border);
    transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.pf-esp32emu-color-modal .pf-esp32emu-resistor-help-card:hover {
    transform: translateY(-2px);
    border-color: var(--pf-esp32emu-overlay-accent);
    box-shadow: 0 8px 18px rgba(18, 32, 56, 0.12);
}

.pf-esp32emu-color-modal-grid {
    margin: 0;
    gap: 10px;
}

.pf-esp32emu-color-modal .pf-esp32emu-siggen-editor {
    background: linear-gradient(165deg, color-mix(in srgb, var(--pf-esp32emu-overlay-surface) 74%, var(--pf-esp32emu-overlay-panel) 26%), var(--pf-esp32emu-overlay-panel));
    border-color: var(--pf-esp32emu-overlay-border);
    border-radius: 12px;
    padding: 12px;
    gap: 10px;
}

.pf-esp32emu-motion-variant-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

/* Force overlays to be two-column and avoid horizontal scrollbars */
.pf-esp32emu-color-modal .pf-esp32emu-color-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    align-items: start;
    width: 100%;
    box-sizing: border-box;
    overflow: visible;
}
.pf-esp32emu-color-modal .pf-esp32emu-color-grid .pf-esp32emu-choice-btn {
    min-width: 0;
}
.pf-esp32emu-choice-preview svg {
    max-width: 100%;
    height: auto;
    display: block;
}

.pf-esp32emu-motion-variant-grid .pf-esp32emu-choice-btn {
    min-height: 148px;
}

.pf-esp32emu-choice-btn {
    background: linear-gradient(165deg, color-mix(in srgb, var(--pf-esp32emu-overlay-input) 92%, #ffffff 8%), color-mix(in srgb, var(--pf-esp32emu-overlay-input) 84%, var(--pf-esp32emu-overlay-panel) 16%));
    border-color: var(--pf-esp32emu-overlay-border);
    color: var(--pf-esp32emu-overlay-text);
    border-radius: 10px;
    transition: transform 0.22s cubic-bezier(0.25, 0.8, 0.25, 1), border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.pf-esp32emu-choice-btn:hover {
    border-color: var(--pf-esp32emu-overlay-accent);
    transform: translateY(-2px);
    box-shadow: 0 8px 18px rgba(12, 28, 46, 0.18);
}

.pf-esp32emu-choice-btn.is-selected {
    border-color: var(--pf-esp32emu-overlay-accent);
    background: linear-gradient(165deg, color-mix(in srgb, var(--pf-esp32emu-overlay-accent-soft) 72%, var(--pf-esp32emu-overlay-input) 28%), color-mix(in srgb, var(--pf-esp32emu-overlay-input) 86%, var(--pf-esp32emu-overlay-panel) 14%));
    box-shadow: var(--pf-esp32emu-overlay-glow);
}

.pf-esp32emu-choice-preview {
    filter: var(--pf-esp32emu-overlay-svg-filter);
    transition: transform 0.25s ease;
}

.pf-esp32emu-choice-btn:hover .pf-esp32emu-choice-preview {
    transform: scale(1.04);
}

.pf-esp32emu-choice-meta {
    color: color-mix(in srgb, var(--pf-esp32emu-overlay-accent) 86%, #21c977 14%);
    font-family: Consolas, 'Courier New', monospace;
    font-weight: 700;
}

.pf-esp32emu-choice-usage {
    color: var(--pf-esp32emu-overlay-muted);
}

.pf-esp32emu-color-modal .pf-esp32emu-siggen-field {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--pf-esp32emu-overlay-border);
    border-radius: 9px;
    background: color-mix(in srgb, var(--pf-esp32emu-overlay-input) 82%, var(--pf-esp32emu-overlay-panel) 18%);
}

.pf-esp32emu-color-modal .pf-esp32emu-siggen-field > span {
    font-size: 0.82rem;
    color: var(--pf-esp32emu-overlay-text);
}

.pf-esp32emu-color-modal .pf-esp32emu-siggen-field > input,
.pf-esp32emu-color-modal .pf-esp32emu-siggen-field > select {
    width: auto;
    min-width: 92px;
    text-align: right;
    border-color: transparent;
    background: transparent;
    color: var(--pf-esp32emu-overlay-accent);
    font-family: Consolas, 'Courier New', monospace;
    font-weight: 700;
    padding: 0;
    height: auto;
}

.pf-esp32emu-color-modal .pf-esp32emu-siggen-switch {
    padding: 10px 12px;
    border: 1px solid var(--pf-esp32emu-overlay-border);
    border-radius: 9px;
    background: color-mix(in srgb, var(--pf-esp32emu-overlay-input) 86%, var(--pf-esp32emu-overlay-panel) 14%);
    color: var(--pf-esp32emu-overlay-text);
    font-size: 0.82rem;
}

.pf-esp32emu-color-modal .pf-esp32emu-siggen-switch input[type="checkbox"] {
    appearance: none;
    width: 38px;
    height: 20px;
    border-radius: 999px;
    background: #5f738a;
    position: relative;
    border: 1px solid transparent;
    transition: background-color 0.2s ease;
}

.pf-esp32emu-color-modal .pf-esp32emu-siggen-switch input[type="checkbox"]::after {
    content: '';
    position: absolute;
    top: 1px;
    left: 1px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    transition: transform 0.2s ease;
}

.pf-esp32emu-color-modal .pf-esp32emu-siggen-switch input[type="checkbox"]:checked {
    background: #26c281;
}

.pf-esp32emu-color-modal .pf-esp32emu-siggen-switch input[type="checkbox"]:checked::after {
    transform: translateX(18px);
}

.pf-esp32emu-color-modal .pf-esp32emu-siggen-preview {
    position: relative;
    overflow: hidden;
    color: var(--pf-esp32emu-overlay-preview-text);
    background: var(--pf-esp32emu-overlay-preview-bg);
    border-color: color-mix(in srgb, var(--pf-esp32emu-overlay-accent) 36%, #1c2732 64%);
    border-left: 4px solid color-mix(in srgb, var(--pf-esp32emu-overlay-accent) 55%, #21c977 45%);
    font-family: Consolas, 'Courier New', monospace;
}

.pf-esp32emu-color-modal .pf-esp32emu-siggen-preview::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.2) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.05), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.05));
    background-size: 100% 2px, 3px 100%;
    pointer-events: none;
    opacity: 0.34;
}

.pf-esp32emu-color-modal .pf-esp32emu-siggen-preview::after {
    content: "_";
    position: absolute;
    right: 10px;
    bottom: 7px;
    color: var(--pf-esp32emu-overlay-preview-text);
    animation: pf-esp32emu-overlay-blink 1s steps(1) infinite;
}

@keyframes pf-esp32emu-overlay-card-in {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes pf-esp32emu-overlay-blink {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0;
    }
}

@media (max-width: 920px) {
    .pf-esp32emu-color-modal > .pf-esp32emu-modal-card.is-help-layout .pf-esp32emu-modal-body {
        grid-template-columns: 1fr;
    }

    .pf-esp32emu-color-modal-help {
        position: static;
    }
}

@media (max-width: 620px) {
    .pf-esp32emu-motion-variant-grid {
        grid-template-columns: 1fr;
    }
}

/* Specific override for LED selection modal to ensure wider layout and two-column grid */
.pf-esp32emu-color-modal > .pf-esp32emu-modal-card.is-led-mode {
    width: min(900px, calc(100vw - 32px));
}
.pf-esp32emu-color-modal > .pf-esp32emu-modal-card.is-led-mode .pf-esp32emu-modal-body {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}
.pf-esp32emu-color-modal > .pf-esp32emu-modal-card.is-led-mode .pf-esp32emu-color-modal-grid.is-led {
    display: grid;
    grid-template-columns: repeat(2, minmax(140px, 1fr));
    gap: 12px;
}

/* Compact layout for resistor + capacitor selection (uses is-resistor-mode for both) */
.pf-esp32emu-color-modal > .pf-esp32emu-modal-card.is-resistor-mode .pf-esp32emu-color-modal-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(110px, 1fr));
    gap: 10px;
    align-items: start;
}
.pf-esp32emu-color-modal > .pf-esp32emu-modal-card.is-resistor-mode .pf-esp32emu-choice-btn {
    padding: 8px 10px;
    gap: 10px;
    align-items: center;
    min-height: 80px;
}
.pf-esp32emu-color-modal > .pf-esp32emu-modal-card.is-resistor-mode .pf-esp32emu-choice-preview svg {
    width: 64px;
    height: auto;
}
.pf-esp32emu-color-modal > .pf-esp32emu-modal-card.is-resistor-mode .pf-esp32emu-choice-label {
    font-size: 13px;
}
.pf-esp32emu-color-modal > .pf-esp32emu-modal-card.is-resistor-mode .pf-esp32emu-resistor-help {
    flex: 0 0 240px;
}

@media (max-width: 1100px) {
    .pf-esp32emu-color-modal > .pf-esp32emu-modal-card.is-resistor-mode .pf-esp32emu-color-modal-grid {
        grid-template-columns: repeat(2, minmax(120px, 1fr));
    }
}
@media (max-width: 720px) {
    .pf-esp32emu-color-modal > .pf-esp32emu-modal-card.is-resistor-mode .pf-esp32emu-color-modal-grid {
        grid-template-columns: 1fr;
    }
    .pf-esp32emu-color-modal > .pf-esp32emu-modal-card.is-resistor-mode .pf-esp32emu-resistor-help { display: none; }
}

/* =========================
   Extra compact display help
   ========================= */
.pf-esp32emu-help-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.pf-esp32emu-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--pf-esp32emu-accent-soft) 72%, var(--pf-esp32emu-panel) 28%);
    color: var(--pf-esp32emu-accent-strong);
    font-size: 0.72rem;
    border: 1px solid color-mix(in srgb, var(--pf-esp32emu-accent) 14%, transparent 86%);
}

.pf-esp32emu-compact-list { margin: 0 0 0 12px; padding: 0; font-size: 0.86rem; }
.pf-esp32emu-compact-list li { margin-bottom: 6px; }

.pf-esp32emu-display-help.compact {
    display: grid;
    gap: 14px;
    padding: 4px 0 2px;
}

.pf-esp32emu-display-help.compact .pf-esp32emu-help-header {
    display: grid;
    gap: 8px;
    padding: 14px 16px;
    border: 1px solid color-mix(in srgb, var(--pf-esp32emu-overlay-accent, var(--pf-esp32emu-cyan)) 18%, transparent 82%);
    border-radius: 16px;
    background:
        radial-gradient(circle at top right, color-mix(in srgb, var(--pf-esp32emu-overlay-accent, var(--pf-esp32emu-cyan)) 18%, transparent 82%), transparent 38%),
        linear-gradient(155deg, color-mix(in srgb, var(--pf-esp32emu-overlay-panel, var(--pf-esp32emu-panel)) 88%, #ffffff 12%), color-mix(in srgb, var(--pf-esp32emu-overlay-surface, var(--pf-esp32emu-panel-soft)) 78%, var(--pf-esp32emu-overlay-panel, var(--pf-esp32emu-panel)) 22%));
    box-shadow: 0 12px 28px rgba(18, 32, 56, 0.10);
}

.pf-esp32emu-display-help.compact .pf-esp32emu-help-header strong {
    display: block;
    font-size: 1.02rem;
    line-height: 1.25;
    color: var(--pf-esp32emu-overlay-text, var(--pf-esp32emu-text));
}

.pf-esp32emu-display-help.compact .pf-esp32emu-help-header > span {
    display: block;
    font-size: 0.88rem;
    line-height: 1.5;
    color: var(--pf-esp32emu-overlay-muted, var(--pf-esp32emu-muted));
}

.pf-esp32emu-display-help.compact .pf-esp32emu-help-meta {
    margin-top: 2px;
    gap: 8px;
}

.pf-esp32emu-display-help.compact .pf-esp32emu-help-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    align-items: stretch;
}

@media (min-width: 980px) {
    .pf-esp32emu-display-help.compact .pf-esp32emu-help-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.pf-esp32emu-display-help.compact .pf-esp32emu-help-card {
    display: grid;
    gap: 10px;
    min-height: 100%;
    padding: 14px 15px;
    border-radius: 14px;
    border: 1px solid color-mix(in srgb, var(--pf-esp32emu-overlay-border, var(--pf-esp32emu-border)) 82%, #ffffff 18%);
    background:
        linear-gradient(180deg, color-mix(in srgb, var(--pf-esp32emu-overlay-surface, var(--pf-esp32emu-panel)) 82%, #ffffff 18%), color-mix(in srgb, var(--pf-esp32emu-overlay-panel, var(--pf-esp32emu-panel-soft)) 92%, #dfe9f5 8%));
    box-shadow: 0 10px 24px rgba(18, 32, 56, 0.08);
    font-size: 0.86rem;
    line-height: 1.55;
    color: var(--pf-esp32emu-overlay-text, var(--pf-esp32emu-text));
}

.pf-esp32emu-display-help.compact .pf-esp32emu-help-card strong {
    display: block;
    font-size: 0.8rem;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: color-mix(in srgb, var(--pf-esp32emu-overlay-accent, var(--pf-esp32emu-cyan)) 74%, var(--pf-esp32emu-overlay-text, var(--pf-esp32emu-text)) 26%);
}

.pf-esp32emu-display-help.compact.is-oled .pf-esp32emu-help-card strong {
    color: color-mix(in srgb, #0d8fc2 76%, var(--pf-esp32emu-overlay-text, var(--pf-esp32emu-text)) 24%);
}

.pf-esp32emu-display-help.compact.is-lcd .pf-esp32emu-help-card strong {
    color: color-mix(in srgb, #4f8a57 75%, var(--pf-esp32emu-overlay-text, var(--pf-esp32emu-text)) 25%);
}

.pf-esp32emu-display-help.compact.is-oled .pf-esp32emu-help-card.is-spec,
.pf-esp32emu-display-help.compact.is-oled .pf-esp32emu-help-card.is-tip {
    background: linear-gradient(180deg, #f1fbff, #e6f4fb);
}

.pf-esp32emu-display-help.compact.is-lcd .pf-esp32emu-help-card.is-spec,
.pf-esp32emu-display-help.compact.is-lcd .pf-esp32emu-help-card.is-tip {
    background: linear-gradient(180deg, #f3fbf3, #e8f3ea);
}

.pf-esp32emu-display-help.compact .pf-esp32emu-help-card.is-spec,
.pf-esp32emu-display-help.compact .pf-esp32emu-help-card.is-tip,
.pf-esp32emu-display-help.compact .pf-esp32emu-help-card.is-range {
    align-content: start;
}

.pf-esp32emu-display-help.compact .pf-esp32emu-help-card.is-spec span,
.pf-esp32emu-display-help.compact .pf-esp32emu-help-card.is-tip span,
.pf-esp32emu-display-help.compact .pf-esp32emu-help-card.is-range span {
    font-size: 0.82rem;
    line-height: 1.65;
}

.pf-esp32emu-display-help.compact .pf-esp32emu-help-card span,
.pf-esp32emu-display-help.compact .pf-esp32emu-help-card ul,
.pf-esp32emu-display-help.compact .pf-esp32emu-help-card li,
.pf-esp32emu-display-help.compact .pf-esp32emu-help-card code {
    color: var(--pf-esp32emu-overlay-text, var(--pf-esp32emu-text));
}

.pf-esp32emu-display-help.compact .pf-esp32emu-compact-list {
    margin: 0;
    padding-left: 18px;
    display: grid;
    gap: 7px;
}

.pf-esp32emu-display-help.compact .pf-esp32emu-compact-list li {
    margin: 0;
    line-height: 1.5;
}

.pf-esp32emu-display-help.compact .pf-esp32emu-help-card code {
    display: block;
    white-space: pre-line;
    font-size: 0.78rem;
    line-height: 1.65;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid color-mix(in srgb, var(--pf-esp32emu-overlay-border, var(--pf-esp32emu-border)) 85%, transparent 15%);
    background: linear-gradient(180deg, color-mix(in srgb, var(--pf-esp32emu-overlay-panel, var(--pf-esp32emu-panel)) 94%, #ffffff 6%), color-mix(in srgb, var(--pf-esp32emu-overlay-surface, var(--pf-esp32emu-panel-soft)) 72%, #eaf3fb 28%));
    color: color-mix(in srgb, var(--pf-esp32emu-overlay-accent, var(--pf-esp32emu-cyan)) 22%, var(--pf-esp32emu-overlay-text, var(--pf-esp32emu-text)) 78%);
    overflow-wrap: anywhere;
}

.pf-esp32emu-display-help.compact .pf-esp32emu-help-card code::before {
    content: 'Verdrahtung';
    display: block;
    margin-bottom: 6px;
    font-size: 0.64rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--pf-esp32emu-overlay-muted, var(--pf-esp32emu-muted));
}

.pf-esp32emu-help-card { padding: 8px; font-size: 0.86rem; }

@media (max-width: 640px) {
    .pf-esp32emu-display-help.compact {
        gap: 10px;
    }

    .pf-esp32emu-display-help.compact .pf-esp32emu-help-header,
    .pf-esp32emu-display-help.compact .pf-esp32emu-help-card {
        padding: 12px;
    }
}

/* very dense variant (use by adding class is-compact on modal card) */
.pf-esp32emu-color-modal > .pf-esp32emu-modal-card.is-compact .pf-esp32emu-color-modal-help { flex: 0 0 160px; }
.pf-esp32emu-color-modal > .pf-esp32emu-modal-card.is-compact .pf-esp32emu-help-card { padding: 6px; font-size: 0.8rem; }
.pf-esp32emu-color-modal > .pf-esp32emu-modal-card.is-compact .pf-esp32emu-display-help.compact .pf-esp32emu-help-header,
.pf-esp32emu-color-modal > .pf-esp32emu-modal-card.is-compact .pf-esp32emu-display-help.compact .pf-esp32emu-help-card {
    padding: 14px 15px;
}

.pf-esp32emu-color-modal > .pf-esp32emu-modal-card.is-compact .pf-esp32emu-display-help.compact .pf-esp32emu-help-card {
    font-size: 0.86rem;
}

@media (max-width: 640px) {
    .pf-esp32emu-color-modal > .pf-esp32emu-modal-card.is-compact .pf-esp32emu-display-help.compact .pf-esp32emu-help-header,
    .pf-esp32emu-color-modal > .pf-esp32emu-modal-card.is-compact .pf-esp32emu-display-help.compact .pf-esp32emu-help-card {
        padding: 12px;
    }
}
