#hid-webapp .pcb-layout {
    width: 100%;
    box-sizing: border-box;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    pointer-events: none;
    height: 0;
    overflow: hidden;
    transition:
        opacity 0.6s ease,
        visibility 0.6s,
        transform 0.6s ease,
        height 0.6s ease;
}

#hid-webapp .pcb-layout.show {
    opacity: 1;
    visibility: visible;
    transform: none;
    pointer-events: auto;
    height: auto;
    overflow: visible;
}

/* The mouse cards fold away while the dongle stays connected without a mouse. */
#hid-webapp .pcb-layout.greyed .sensor-settings-card,
#hid-webapp .pcb-layout.greyed .click-assignments-card {
    opacity: 0;
    visibility: hidden;
    transform: translateY(-18px);
    pointer-events: none;
    transition:
        opacity 0.45s ease,
        visibility 0.45s,
        transform 0.45s ease;
}

#hid-webapp .pcb-layout.greyed-instant .sensor-settings-card,
#hid-webapp .pcb-layout.greyed-instant .click-assignments-card {
    transition: none;
}

#hid-webapp .settings-cards-layout .settings-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    opacity: 1;
    visibility: inherit;
    pointer-events: auto;
    height: auto;
    overflow: visible;
    transition: none;
}

#hid-webapp .settings-top-row {
    position: relative;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    align-items: stretch;
    min-width: 0;
    width: 100%;
}

#hid-webapp .mouse-ghost,
#hid-webapp .mouse-sleeping {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
    z-index: 1;
}

#hid-webapp .mouse-ghost img,
#hid-webapp .mouse-sleeping img {
    width: clamp(120px, 22vw, 220px);
    opacity: 0.35;
    filter: grayscale(100%) brightness(0.7);
}

#hid-webapp .pcb-layout.ghost .mouse-ghost,
#hid-webapp .pcb-layout.sleeping .mouse-sleeping {
    opacity: 1;
    transition: opacity 0.5s ease 0.35s;
}

#hid-webapp .settings-card {
    background: rgba(0, 0, 0, 0.03);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 0.875rem;
    padding: 1.5rem 1.75rem;
    text-align: left;
    box-sizing: border-box;
    min-width: 0;
    width: 100%;
    transition:
        opacity 0.4s ease,
        transform 0.4s ease;
}

#hid-webapp .sensor-settings-card,
#hid-webapp .click-assignments-card {
    min-height: 30rem;
    display: flex;
    flex-direction: column;
}

#hid-webapp.dark-mode .settings-card {
    background: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.07);
}

#hid-webapp .settings-card-title {
    font-family: "Orbitron", "Orbitron Fallback", sans-serif;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--accent-color);
    letter-spacing: 0.06em;
    margin: 0 0 1.25rem 0;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

#hid-webapp.dark-mode .settings-card-title {
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

#hid-webapp .sensor-settings-body {
    display: flex;
    gap: 0;
    align-items: stretch;
    flex: 1;
}

#hid-webapp .sensor-controls-col {
    display: flex;
    flex-direction: column;
    gap: 0;
    flex: 0 0 50%;
    min-width: 0;
    padding-right: 1.5rem;
    border-right: 1px solid rgba(0, 0, 0, 0.1);
    justify-content: space-between;
    box-sizing: border-box;
    align-self: stretch;
}

#hid-webapp.dark-mode .sensor-controls-col {
    border-right-color: rgba(255, 255, 255, 0.1);
}

/* Advanced-only rows keep their space so the card does not resize. */
#hid-webapp .settings-cards-layout .control-dpi-y,
#hid-webapp .settings-cards-layout .control-lift,
#hid-webapp .settings-cards-layout .control-deep-sleep,
#hid-webapp .settings-cards-layout .control-button-debounce {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.6s ease;
}

#hid-webapp.advanced-mode .settings-cards-layout .control-dpi-y,
#hid-webapp.advanced-mode .settings-cards-layout .control-lift,
#hid-webapp.advanced-mode .settings-cards-layout .control-deep-sleep,
#hid-webapp.advanced-mode .settings-cards-layout .control-button-debounce {
    opacity: 1;
    pointer-events: auto;
    transition: opacity 0.6s ease;
}

#hid-webapp.leaving-advanced-mode .settings-cards-layout .control-dpi-y,
#hid-webapp.leaving-advanced-mode .settings-cards-layout .control-lift,
#hid-webapp.leaving-advanced-mode .settings-cards-layout .control-deep-sleep,
#hid-webapp.leaving-advanced-mode .settings-cards-layout .control-button-debounce {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

#hid-webapp .sensor-control-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
}

#hid-webapp .control-lift {
    align-items: flex-start;
}

#hid-webapp .advanced-sensor-controls-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    width: 100%;
}

#hid-webapp .deep-sleep-timeout-input-row,
#hid-webapp .sensor-input-unit-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#hid-webapp .deep-sleep-timeout-input-row .sensor-number-input,
#hid-webapp .sensor-input-unit-row .sensor-number-input {
    flex: 1 1 auto;
    min-width: 0;
}

#hid-webapp .deep-sleep-timeout-unit,
#hid-webapp .sensor-input-unit {
    font-size: 0.92rem;
    white-space: nowrap;
}

#hid-webapp .sensor-control-label {
    font-size: 0.95rem;
    font-weight: 600;
    color: #444;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

#hid-webapp.dark-mode .sensor-control-label {
    color: #ccc;
}

#hid-webapp .sensor-controls-col select {
    width: 9.375rem;
    padding: 0.55rem 2rem 0.55rem 0.85rem;
    font-size: 0.92rem;
}

#hid-webapp .advanced-sensor-controls-row .control-lift select {
    width: 100%;
}

#hid-webapp .sensor-slider-row {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
}

#hid-webapp .sensor-label-input-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

#hid-webapp .sensor-slider {
    width: 100%;
    flex-shrink: 0;
}

#hid-webapp .sensor-number-input {
    width: 4rem;
    padding: 0.35rem 0.5rem;
    font-size: 0.92rem;
    flex-shrink: 0;
}

#hid-webapp .advanced-sensor-controls-row .sensor-number-input {
    width: 100%;
    padding: 0.55rem 0.85rem;
}

#hid-webapp .settings-cards-layout .dpi-row-1 {
    position: relative;
    min-height: 4.5rem;
}

/* Combined DPI and DPI X share one slot and crossfade with Advanced Mode. */
#hid-webapp .settings-cards-layout .dpi-combined-wrap,
#hid-webapp .settings-cards-layout .dpi-x-wrap {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    transition: opacity 0.3s ease;
}

#hid-webapp .settings-cards-layout .dpi-combined-wrap {
    opacity: 1;
    pointer-events: auto;
}

#hid-webapp.advanced-mode .settings-cards-layout .dpi-combined-wrap {
    opacity: 0;
    pointer-events: none;
}

#hid-webapp .settings-cards-layout .dpi-x-wrap {
    opacity: 0;
    pointer-events: none;
}

#hid-webapp.advanced-mode .settings-cards-layout .dpi-x-wrap {
    opacity: 1;
    pointer-events: auto;
}

#hid-webapp.leaving-advanced-mode .settings-cards-layout .dpi-combined-wrap {
    opacity: 1;
}

#hid-webapp.leaving-advanced-mode .settings-cards-layout .dpi-x-wrap {
    opacity: 0;
}

/* A profile without a DPI split keeps the combined DPI in Advanced Mode. */
#hid-webapp.advanced-mode .settings-cards-layout .single-dpi .dpi-combined-wrap {
    opacity: 1;
    pointer-events: auto;
}

#hid-webapp .settings-cards-layout .single-dpi .dpi-x-wrap,
#hid-webapp .settings-cards-layout .single-dpi .control-dpi-y {
    visibility: hidden;
}

#hid-webapp .sensor-pcb-col {
    flex: 0 0 50%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    padding-left: 1.5rem;
    box-sizing: border-box;
}

#hid-webapp .sensor-pcb-image {
    width: 100%;
    flex: 0 0 auto;
    height: auto;
    max-width: none;
    object-fit: contain;
    display: block;
    border-radius: 0.5rem;
}

#hid-webapp .axis-orientation-box {
    width: 100%;
    max-width: none;
    border: none;
    border-radius: 0;
    padding: 0;
    background: none;
    box-sizing: border-box;
}

#hid-webapp .axis-orientation-title {
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    color: #444;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

#hid-webapp.dark-mode .axis-orientation-title {
    color: #ccc;
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

#hid-webapp .axis-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.3rem 0;
}

#hid-webapp .axis-row-label {
    font-size: 0.95rem;
    font-weight: 600;
    color: #444;
}

#hid-webapp.dark-mode .axis-row-label {
    color: #ccc;
}

#hid-webapp .control-invert-x-y-swap {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.6s ease;
}

#hid-webapp.advanced-mode .control-invert-x-y-swap {
    opacity: 1;
    pointer-events: auto;
    transition: opacity 0.6s ease;
}

#hid-webapp.leaving-advanced-mode .control-invert-x-y-swap {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

#hid-webapp .no-axis-orientation .control-invert-x-y-swap {
    visibility: hidden;
}

#hid-webapp .click-assignments-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    justify-content: center;
}

#hid-webapp .click-layout {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    width: 100%;
}

#hid-webapp .click-bottom-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    width: 100%;
}

#hid-webapp .click-assignment-select {
    position: absolute;
    width: 7.5rem;
    padding: 0.5rem 1.5rem 0.5rem 0.75rem;
    font-size: 0.78rem;
    font-weight: 600;
    border-radius: 0.5rem;
    border: 1px solid #ccc;
    background-color: transparent;
    color: inherit;
    background-image: var(--select-arrow);
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    background-size: 10px;
    appearance: none;
    cursor: pointer;
    box-sizing: border-box;
    flex: none;
}

#hid-webapp .click-mouse-image-wrap {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: visible;
}

#hid-webapp .click-mouse-image {
    height: 15rem;
    width: auto;
    object-fit: contain;
    display: block;
}

#hid-webapp .click-dot {
    position: absolute;
    width: 0.8125rem;
    height: 0.8125rem;
    border-radius: 50%;
    background: var(--accent-color);
    box-shadow:
        0 0 0 3px rgba(var(--accent-rgb), 0.35),
        0 0 8px rgba(var(--accent-rgb), 0.5);
    pointer-events: none;
    z-index: 2;
}

#hid-webapp .click-connectors-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: visible;
    z-index: 1;
}

#hid-webapp .click-connector-line {
    stroke: var(--accent-color);
    stroke-width: 1.5;
    stroke-opacity: 0.55;
    fill: none;
}

#hid-webapp .click-assignments-card.click-assign-gated {
    opacity: 0.4;
    pointer-events: none;
    cursor: not-allowed;
    position: relative;
}

#hid-webapp .click-assignments-card.click-assign-gated::after {
    content: "Update firmware to v1.0.0+ to unlock Click Assignments";
    position: absolute;
    bottom: 1.25rem;
    right: 1.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-align: right;
    color: var(--accent-color);
    pointer-events: none;
}

#hid-webapp .device-status-card {
    width: 100%;
}

#hid-webapp .device-status-body {
    display: flex;
    align-items: center;
    gap: 0;
    min-width: 0;
    width: 100%;
    height: 100%;
}

#hid-webapp .device-status-divider {
    width: 1px;
    align-self: stretch;
    background: rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
    margin: 0 2rem;
}

#hid-webapp.dark-mode .device-status-divider {
    background: rgba(255, 255, 255, 0.1);
}

#hid-webapp .device-status-connection {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
}

#hid-webapp .device-name-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

#hid-webapp .device-status-conn-text {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
}

#hid-webapp .device-name {
    font-size: 1rem;
    font-weight: 700;
    color: #222;
}

#hid-webapp.dark-mode .device-name {
    color: #e5e7eb;
}

#hid-webapp .mouse-disconnected-warning {
    font-size: 0.85rem;
    color: #b45309;
    margin-top: 0.35rem;
    padding-left: calc(0.6875rem + 0.6rem);
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

#hid-webapp.dark-mode .mouse-disconnected-warning {
    color: #fbbf24;
}

/* A mouse the dongle lost may be on its USB cable, which this browser has not been given yet. */
#hid-webapp .usb-offer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem 0.6rem;
    margin-top: 0.5rem;
    padding-left: calc(0.6875rem + 0.6rem);
    font-size: 0.85rem;
    color: var(--text-secondary);
}

#hid-webapp .usb-offer-btn {
    font-size: 0.8rem;
    padding: 0.2rem 0.65rem;
}

#hid-webapp .usb-offer-note {
    flex-basis: 100%;
    margin: 0;
    color: var(--text-muted);
}

#hid-webapp .usb-offer-note:empty {
    display: none;
}

#hid-webapp .device-id-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.2rem 0.5rem;
    min-width: 0;
    padding-left: calc(0.6875rem + 0.6rem);
}

#hid-webapp .device-wireless-id {
    font-size: 1rem;
    font-weight: 700;
    color: #6b7280;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.6s ease;
}

#hid-webapp .device-transport {
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    background: rgba(0, 0, 0, 0.06);
    border-radius: 0.375rem;
    padding: 0.15rem 0.5rem;
    color: #333;
    opacity: 0;
    transition: opacity 0.6s ease;
}

#hid-webapp.dark-mode .device-transport {
    background: rgba(255, 255, 255, 0.08);
    color: #e5e7eb;
}

#hid-webapp .device-transport:empty {
    display: none;
}

#hid-webapp .device-wireless-id.show,
#hid-webapp .device-transport.show {
    opacity: 1;
}

#hid-webapp .device-status-dot {
    width: 0.6875rem;
    height: 0.6875rem;
    border-radius: 50%;
    background: #4ade80;
    box-shadow: 0 0 6px rgba(74, 222, 128, 0.5);
    flex-shrink: 0;
    display: none;
    transition:
        background 0.3s ease,
        box-shadow 0.3s ease;
}

#hid-webapp .device-status-dot.visible {
    display: block;
}

#hid-webapp .device-status-dot.disconnected {
    background: #9ca3af;
    box-shadow: 0 0 6px rgba(156, 163, 175, 0.4);
}

#hid-webapp .device-status-fw-col {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    flex: 1;
    min-width: 0;
    justify-content: center;
}

#hid-webapp .fw-badge-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#hid-webapp .fw-badge-dot {
    width: 0.5625rem;
    height: 0.5625rem;
    border-radius: 50%;
    background: #4ade80;
    box-shadow: 0 0 5px rgba(74, 222, 128, 0.5);
    flex-shrink: 0;
}

#hid-webapp .fw-badge-dot.outdated {
    background: #ef4444;
    box-shadow: 0 0 5px rgba(239, 68, 68, 0.5);
}

#hid-webapp .fw-badge-dot.unknown {
    background: #6b7280;
    box-shadow: 0 0 5px rgba(107, 114, 128, 0.5);
}

#hid-webapp .fw-badge-label {
    font-size: 1rem;
    font-weight: 700;
    color: #222;
    flex: 1;
}

#hid-webapp.dark-mode .fw-badge-label {
    color: #e5e7eb;
}

#hid-webapp .fw-badge-version {
    font-family: monospace;
    font-size: 0.85rem;
    font-weight: 600;
    background: rgba(0, 0, 0, 0.06);
    border-radius: 0.375rem;
    padding: 0.15rem 0.5rem;
    color: #333;
}

#hid-webapp.dark-mode .fw-badge-version {
    background: rgba(255, 255, 255, 0.08);
    color: #e5e7eb;
}

/* Support asks for these, so they can be copied. */
#hid-webapp .device-wireless-id,
#hid-webapp .fw-badge-version {
    user-select: text;
}

#hid-webapp .firmware-update-section {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    align-items: center;
    justify-content: flex-start;
    gap: 0.5rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

#hid-webapp .firmware-update-section.show {
    opacity: 1;
    pointer-events: auto;
}

#hid-webapp .firmware-update-row {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
}

#hid-webapp .fw-update-card-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 1.4rem;
    font-size: 0.95rem;
    border-radius: 0.625rem;
}

#hid-webapp .fw-update-card-btn:disabled,
#hid-webapp .fw-update-card-btn[aria-disabled="true"] {
    opacity: 0.4;
    pointer-events: none;
}

#hid-webapp .fw-update-icon {
    font-size: 1.1rem;
    line-height: 1;
}

#hid-webapp .fw-update-hint,
#hid-webapp .fw-update-note {
    font-size: 0.78rem;
    color: #888;
}

#hid-webapp.dark-mode .fw-update-hint,
#hid-webapp.dark-mode .fw-update-note {
    color: #6b7280;
}

#hid-webapp .fw-update-note {
    text-align: center;
}

@media (max-width: 800px) and (pointer: coarse) {
    #hid-webapp .pcb-layout {
        display: none !important;
    }
}

#hid-webapp .debounce-controls-row .sensor-control-label {
    white-space: nowrap;
}
