#hid-webapp .power-off-confirm-body,
#hid-webapp .clear-board-confirm-body,
#hid-webapp .usb-offer-modal-body,
#hid-webapp .reset-defaults-confirm-body {
    font-size: 0.9em;
    line-height: 1.4;
    color: inherit;
}

#hid-webapp .power-off-confirm-body p {
    margin: 0 0 0.6rem;
}

#hid-webapp .power-off-confirm-body p:last-child {
    margin-bottom: 0;
}

#hid-webapp .power-off-usb-warning {
    display: none;
}

#hid-webapp .power-off-confirm-body.usb-present .power-off-usb-warning {
    display: block;
}

#hid-webapp .power-off-confirm-body.usb-present .power-off-battery-note {
    display: none;
}

#hid-webapp .clear-board-confirm-body p {
    margin: 0;
}

#hid-webapp .usb-offer-modal-body p {
    margin: 0;
}

#hid-webapp .usb-offer-modal-body .usb-offer-modal-note {
    margin-top: 0.6rem;
    color: var(--text-muted);
}

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

#hid-webapp .reset-defaults-confirm-body p {
    margin: 0 0 0.6rem;
}

#hid-webapp .reset-defaults-confirm-body ul {
    margin: 0;
    padding-left: 1.25rem;
}

#hid-webapp .reset-defaults-confirm-body ul li {
    margin-bottom: 0.25rem;
}

#hid-webapp .reset-defaults-confirm-body ul li:last-child {
    margin-bottom: 0;
}

#hid-webapp .modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.25s ease;
}

#hid-webapp .modal-overlay.show {
    display: flex;
}

/* The panel scrolls in a short window; 6rem covers its padding plus a margin. */
#hid-webapp .modal-overlay > * {
    max-height: calc(100vh - 6rem);
    overflow-y: auto;
}

#hid-webapp .modal-overlay.modal-open {
    opacity: 1;
}

#hid-webapp .modal-overlay.modal-closing {
    opacity: 0;
    pointer-events: none;
}

/* The Linux instructions dialog opens without this entrance. */
#hid-webapp .modal-overlay .consent-modal,
#hid-webapp .modal-overlay .fw-update-modal,
#hid-webapp .modal-overlay .modal-panel,
#hid-webapp .modal-overlay .primary-click-warning-modal {
    transform: scale(0.92) translateY(12px);
    opacity: 0;
    transition:
        transform 0.28s cubic-bezier(0.34, 1.4, 0.64, 1),
        opacity 0.22s ease;
}

#hid-webapp .modal-overlay.modal-open .consent-modal,
#hid-webapp .modal-overlay.modal-open .fw-update-modal,
#hid-webapp .modal-overlay.modal-open .modal-panel,
#hid-webapp .modal-overlay.modal-open .primary-click-warning-modal {
    transform: scale(1) translateY(0);
    opacity: 1;
}

#hid-webapp .modal-overlay.modal-closing .consent-modal,
#hid-webapp .modal-overlay.modal-closing .fw-update-modal,
#hid-webapp .modal-overlay.modal-closing .modal-panel,
#hid-webapp .modal-overlay.modal-closing .primary-click-warning-modal {
    transform: scale(0.95) translateY(8px);
    opacity: 0;
    transition:
        transform 0.2s ease,
        opacity 0.2s ease;
}

#hid-webapp .consent-modal {
    background: var(--card-bg);
    border-radius: 1rem;
    padding: 2rem;
    max-width: 28.75rem;
    width: 90%;
    box-shadow: var(--shadow-modal);
}

#hid-webapp .consent-modal-title {
    font-family: "Orbitron", sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent-color);
    margin-bottom: 1.25rem;
}

#hid-webapp .consent-modal-body {
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
}

#hid-webapp .consent-modal-body p {
    margin: 0 0 0.75rem;
}

#hid-webapp .consent-modal-body p:last-child {
    margin-bottom: 0;
}

#hid-webapp .consent-modal-body ul {
    margin: 0 0 0.75rem 1.25rem;
    padding: 0;
}

#hid-webapp .consent-modal-body ul li {
    margin-bottom: 0.25rem;
}

#hid-webapp .consent-modal-links a {
    color: var(--accent-color);
    text-decoration: underline;
}

#hid-webapp .consent-modal-links a:hover,
#hid-webapp .modal-confirm:hover,
#hid-webapp .modal-cancel:hover {
    opacity: 0.8;
}

#hid-webapp .modal-panel {
    background: #fff;
    border-radius: 0.75rem;
    padding: 1.5rem;
    min-width: 16.25rem;
    box-shadow: var(--shadow-modal);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

#hid-webapp .modal-title {
    font-family: Orbitron, sans-serif;
    font-weight: 700;
    font-size: 0.9em;
    color: var(--accent-color);
    letter-spacing: 0.03em;
}

#hid-webapp .wl-channel-modal-input {
    width: 100%;
    box-sizing: border-box;
}

#hid-webapp .wl-channel-modal-warning {
    font-size: 0.8em;
    color: #ef4444;
    min-height: 1em;
}

#hid-webapp .modal-actions {
    display: flex;
    gap: 0.6rem;
    justify-content: flex-end;
}

#hid-webapp .modal-confirm,
#hid-webapp .modal-cancel {
    font-size: 0.85em;
    font-weight: 600;
    padding: 0.4rem 1rem;
    border-radius: 0.375rem;
    border: none;
    cursor: pointer;
    transition: opacity 0.15s;
}

#hid-webapp .modal-confirm {
    background: var(--accent-color);
    color: #fff;
}

#hid-webapp .modal-cancel {
    background: rgba(128, 128, 128, 0.15);
    color: inherit;
}

#hid-webapp .linux-instructions-modal {
    background: #fff;
    border-radius: 0.75rem;
    padding: 1.5rem;
    width: 42.5rem;
    max-width: 92vw;
    box-shadow: var(--shadow-modal);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

#hid-webapp .linux-instructions-body {
    font-size: 0.88rem;
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    text-align: left;
}

#hid-webapp .linux-instructions-body p {
    margin: 0;
}

#hid-webapp .linux-instructions-body ol > li + li {
    margin-top: 1rem;
}

#hid-webapp .linux-instructions-body a {
    color: var(--accent-color);
    text-decoration: none;
}

#hid-webapp .linux-instructions-body a:hover {
    text-decoration: underline;
}

#hid-webapp .linux-instructions-body pre {
    background: rgba(0, 0, 0, 0.06);
    border-radius: 0.375rem;
    padding: 0.6rem 0.8rem;
    margin: 0.1rem 0;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
    user-select: text;
}

#hid-webapp.dark-mode .linux-instructions-body pre {
    background: rgba(255, 255, 255, 0.07);
}

#hid-webapp .linux-instructions-body code {
    font-family: "Roboto Mono", monospace;
    font-size: 0.82rem;
    background: rgba(0, 0, 0, 0.06);
    border-radius: 0.25rem;
    padding: 0.05em 0.3em;
}

#hid-webapp.dark-mode .linux-instructions-body code {
    background: rgba(255, 255, 255, 0.1);
}

#hid-webapp .fw-update-modal {
    background: #fff;
    border-radius: 0.875rem;
    padding: 2rem;
    width: 100%;
    max-width: 33.75rem;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.22);
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    box-sizing: border-box;
}

#hid-webapp.dark-mode .modal-panel,
#hid-webapp.dark-mode .linux-instructions-modal,
#hid-webapp.dark-mode .fw-update-modal {
    background: var(--surface-modal);
    color: #f3f4f6;
}

#hid-webapp .fw-update-modal-title {
    font-family: Orbitron, sans-serif;
    font-weight: 700;
    font-size: 1.4rem;
    color: var(--accent-color);
    letter-spacing: 0.03em;
    text-align: center;
}

@keyframes fw-warning-fadeout {
    0% {
        opacity: 1;
        max-height: 200px;
        margin-bottom: 0;
        padding-top: 0.85rem;
        padding-bottom: 0.85rem;
    }
    60% {
        opacity: 0;
        max-height: 200px;
        margin-bottom: 0;
        padding-top: 0.85rem;
        padding-bottom: 0.85rem;
    }
    100% {
        opacity: 0;
        max-height: 0;
        margin-bottom: -0.75rem;
        padding-top: 0;
        padding-bottom: 0;
        border-width: 0;
    }
}

#hid-webapp .fw-update-modal-warning-box.fw-warning-hide {
    animation: fw-warning-fadeout 0.75s ease forwards;
    overflow: hidden;
    pointer-events: none;
}

#hid-webapp .fw-update-modal-warning-box {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.35);
    border-radius: 0.5rem;
    padding: 0.85rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

#hid-webapp .fw-update-modal-restart-box {
    background: rgba(234, 88, 12, 0.1);
    border-color: rgba(234, 88, 12, 0.4);
}

#hid-webapp .fw-update-modal-warning-header {
    font-size: 0.88rem;
    font-weight: 600;
    color: #b45309;
}

#hid-webapp.dark-mode .fw-update-modal-warning-header {
    color: #fbbf24;
}

#hid-webapp .fw-update-modal-restart-box .fw-update-modal-warning-header {
    color: #9a3412;
}

#hid-webapp.dark-mode .fw-update-modal-restart-box .fw-update-modal-warning-header {
    color: #fb923c;
}

#hid-webapp .fw-update-modal-warning-list {
    margin: 0;
    padding-left: 1.25rem;
    font-size: 0.83rem;
    color: #92400e;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

#hid-webapp.dark-mode .fw-update-modal-warning-list {
    color: #fcd34d;
}

#hid-webapp .fw-update-modal-divider {
    height: 1px;
    background: rgba(128, 128, 128, 0.15);
    margin: 0;
}

#hid-webapp .fw-update-modal-versions {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.88rem;
}

#hid-webapp .fw-update-modal-version-row {
    display: flex;
    gap: 0.5rem;
}

#hid-webapp .fw-update-modal-version-label {
    opacity: 0.55;
    min-width: 7.5rem;
}

#hid-webapp .fw-update-modal-version-value {
    font-weight: 600;
    font-family: monospace;
    font-size: 0.95rem;
}

#fw-update-modal-progress-section {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

#hid-webapp .fw-update-modal-progress-label {
    font-size: 0.8rem;
    font-weight: 600;
    opacity: 0.6;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

#hid-webapp .fw-update-modal-progress-track {
    width: 100%;
    height: 1.375rem;
    background: rgba(128, 128, 128, 0.15);
    border-radius: 0.6875rem;
    overflow: hidden;
}

#hid-webapp .fw-update-modal-progress-fill {
    height: 100%;
    width: 0%;
    background: var(--accent-color);
    border-radius: 0.6875rem;
    transition: width 0.3s ease;
}

#hid-webapp .fw-update-modal-progress-fill.failed {
    background: #ef4444;
}

@keyframes fw-strobe {
    0% {
        background-position: 200% center;
    }
    100% {
        background-position: -200% center;
    }
}

/* Indeterminate progress; overrides the width the update writes inline. */
#hid-webapp .fw-update-modal-progress-fill.strobe {
    width: 100% !important;
    background: linear-gradient(
        90deg,
        rgba(128, 128, 128, 0.15) 0%,
        rgba(128, 128, 128, 0.15) 35%,
        rgba(180, 180, 180, 0.4) 50%,
        rgba(128, 128, 128, 0.15) 65%,
        rgba(128, 128, 128, 0.15) 100%
    );
    background-color: var(--accent-color);
    background-size: 200% 100%;
    animation: fw-strobe 2.4s linear infinite;
    transition: none;
}

#hid-webapp .fw-update-modal-progress-pct {
    font-size: 0.85rem;
    font-weight: 600;
    text-align: right;
    color: var(--accent-color);
}

#hid-webapp .fw-update-modal-status {
    font-size: 0.88rem;
    color: var(--accent-color);
    min-height: 1.2em;
}

#hid-webapp .fw-update-modal-status.error {
    color: #ef4444;
}

#hid-webapp .primary-click-warning-modal {
    background: var(--card-bg);
    border-radius: 1rem;
    padding: 2rem;
    max-width: 20rem;
    width: 90%;
    box-shadow: var(--shadow-modal);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

#hid-webapp .primary-click-warning-modal .modal-title {
    text-transform: uppercase;
    text-align: center;
    color: #f59e0b;
}

#hid-webapp .primary-click-warning-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

#hid-webapp .primary-click-warning-icon {
    font-size: 1.1rem;
    color: #f59e0b;
    flex-shrink: 0;
}

#hid-webapp .primary-click-warning-body {
    font-size: 0.88rem;
    opacity: 0.75;
    line-height: 1.5;
    text-align: center;
}

#hid-webapp .primary-click-warning-timer-track {
    height: 0.25rem;
    border-radius: 0.125rem;
    background: rgba(128, 128, 128, 0.2);
    overflow: hidden;
}

#hid-webapp .primary-click-warning-timer-fill {
    height: 100%;
    width: 100%;
    background: #f59e0b;
    border-radius: 0.125rem;
    transform-origin: left;
    transition: none;
}
