#hid-webapp {
    display: grid;
    /* Each side column fits the sidebar and its margin, so the sidebar never leaves the window. */
    grid-template-columns:
        minmax(6.625rem, 1fr)
        minmax(0, min(81rem, 1800px))
        minmax(6.625rem, 1fr);
    grid-template-rows: 1fr;
}

#hid-webapp .sidebar-col {
    grid-column: 1;
    grid-row: 1;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    min-width: 0;
    overflow: visible;
    /* ui-scale sets the height from the Settings tab, so the sidebar stays put on taller tabs. */
    align-self: start;
    position: sticky;
    top: 0;
    height: var(--sidebar-col-height, 100vh);
}

#hid-webapp .sidebar {
    position: static;
    width: 5.625rem;
    margin-right: 1rem;
    background-color: #e5e7eb;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.5rem 0;
    gap: 1rem;
    z-index: 10;
    border-radius: 0.75rem;
    opacity: 0;
    pointer-events: none;
    transition:
        opacity 0.6s ease,
        background-color 0.3s ease;
    visibility: hidden;
}

#hid-webapp .sidebar.show {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
}

#hid-webapp .col-right {
    grid-column: 3;
    grid-row: 1;
}

#hid-webapp .sidebar-btn {
    width: 3.75rem;
    height: 3.75rem;
    border-radius: 0.75rem;
    background-color: #d1d5db;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition:
        all 0.3s ease,
        opacity 1.2s ease;
    color: #1f2937;
    font-size: 1.5rem;
}

#hid-webapp .sidebar-btn:hover {
    background-color: #c7cad1;
    transform: scale(1.05);
}

#hid-webapp .sidebar-btn.active {
    background-color: var(--accent-color);
    box-shadow: 0 4px 12px rgba(var(--accent-rgb), 0.4);
    color: #fff;
}

#hid-webapp .sidebar-btn img {
    width: 1.875rem;
    height: 1.875rem;
    object-fit: contain;
    filter: brightness(0) saturate(100%);
}

#hid-webapp .sidebar-btn.active img {
    filter: brightness(0) saturate(100%) invert(1);
}

#hid-webapp.dark-mode .sidebar-btn img {
    filter: brightness(0) saturate(100%) invert(1);
}

#hid-webapp .sidebar-btn[data-tab="angle-tuning"] img {
    width: 2.1875rem;
    height: 2.1875rem;
}

#hid-webapp .close-btn {
    margin-bottom: 3rem;
    background-color: transparent;
}

#hid-webapp .close-btn:hover {
    background-color: #d1d5db;
}

#hid-webapp .close-btn .btn-spinner {
    border-color: color-mix(in srgb, currentColor 35%, transparent);
    border-top-color: currentColor;
}

#hid-webapp .close-btn.loading img {
    display: none;
}

/* Sits in the gap under Close, so it takes no room. */
#hid-webapp .close-status {
    height: 2rem;
    margin: -3rem 0 0;
    font-size: 0.75rem;
    line-height: 2rem;
    color: var(--text-muted);
    white-space: nowrap;
}

#hid-webapp .sidebar-btn.advanced-only {
    display: none;
}

#hid-webapp.advanced-mode .sidebar-btn.advanced-only {
    display: flex;
    animation: fadeInScale 0.6s ease forwards;
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.5);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes fadeOutScale {
    from {
        opacity: 1;
        transform: scale(1);
    }

    to {
        opacity: 0;
        transform: scale(0.5);
    }
}

#hid-webapp.leaving-advanced-mode .sidebar-btn.advanced-only {
    display: flex;
    animation: fadeOutScale 0.3s ease forwards;
}

#hid-webapp .main-content {
    grid-column: 2;
    grid-row: 1;
    width: 100%;
    margin: 0;
    padding: 2rem 0;
    box-sizing: border-box;
}

#hid-webapp .container {
    background-color: var(--card-bg);
    padding: 2.5rem 3rem;
    border-radius: 1rem;
    box-shadow: var(--shadow-card);
    width: 100%;
    box-sizing: border-box;
    /* Room below for the footer, which only the page before a connect shows. */
    min-height: calc(100vh - 9rem);
    text-align: center;
    transition:
        background-color 0.6s ease,
        box-shadow 0.6s ease;
    position: relative;
}

#hid-webapp:has(#tab-settings.active) .container {
    overflow: visible;
}

/* Without the footer, down to the window's bottom margin: the same 2rem as above the card. */
#hid-webapp:has(.footer-section.hide) .container {
    min-height: calc(100vh - 4rem);
}

#hid-webapp.dark-mode .sidebar {
    background-color: #1a1d24;
}

#hid-webapp.dark-mode .sidebar-btn {
    background-color: #2a2f3a;
    color: #fff;
}

#hid-webapp.dark-mode .sidebar-btn:hover {
    background-color: #3a3f4a;
}

/* Repeats .sidebar-btn.active, which the dark-mode rule above would otherwise override. */
#hid-webapp.dark-mode .sidebar-btn.active {
    background-color: var(--accent-color);
    box-shadow: 0 4px 12px rgba(var(--accent-rgb), 0.4);
    color: #fff;
}

#hid-webapp.dark-mode .close-btn {
    background-color: transparent;
}

#hid-webapp.dark-mode .close-btn:hover {
    background-color: #2a2f3a;
}

#hid-webapp .heading-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

#hid-webapp .heading-row h1 {
    margin-bottom: 0;
}

#hid-webapp .safe-mode-warning {
    font-size: 1.8rem;
    color: #f59e0b;
    cursor: default;
    line-height: 1;
    position: relative;
    flex-shrink: 0;
}

#hid-webapp .top-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

/* Under Connect, only while it says why nothing opened. */
#hid-webapp .connect-note {
    flex-basis: 100%;
    margin: 0;
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-muted);
}

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

#hid-webapp .top-bar.hidden {
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
    height: 0;
    margin-bottom: 1.5rem;
}

#hid-webapp #connect {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

#hid-webapp .btn-spinner {
    display: none;
    width: 1em;
    height: 1em;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: btn-spin 0.7s linear infinite;
    flex-shrink: 0;
}

#hid-webapp #connect.loading .btn-spinner,
#hid-webapp .close-btn.loading .btn-spinner {
    display: inline-block;
}

#hid-webapp #connect.loading .btn-label {
    opacity: 0.85;
}

#hid-webapp #connect.loading {
    pointer-events: none;
}

@keyframes btn-spin {
    to {
        transform: rotate(360deg);
    }
}

/* The devices this browser knows, under Connect; hidden while connected or with none. */
#hid-webapp .device-tiles {
    flex: 1 1 auto;
    min-height: 0;
    margin-top: 1rem;
    overflow-y: auto;
}

/* With tiles the card keeps its height and they scroll in the room under Connect, down to its
   bottom. Not while ui-scale measures the connected page (rescaling). */
html:not(.rescaling) #hid-webapp .container:has(#device-tiles:not([hidden])) {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 9rem);
}

html:not(.rescaling) #hid-webapp .container:has(#device-tiles:not([hidden])) > .container-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

/* The padding keeps a focus ring clear of the scrolling edge. */
#hid-webapp .device-tiles-list {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
    max-width: 56rem;
    list-style: none;
    margin: 0 auto;
    padding: 0.25rem;
}

/* A fixed width and one line per row: no name or status makes one tile larger than another. */
#hid-webapp .device-tile {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.28rem;
    box-sizing: border-box;
    width: 13.2rem;
    padding: 1.1rem 0.83rem;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 0.96rem;
    background: rgba(0, 0, 0, 0.03);
    color: var(--text-primary);
    text-align: center;
    transition:
        border-color 0.2s ease,
        background-color 0.2s ease;
}

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

#hid-webapp .device-tile:has(> .device-tile-open:not([aria-disabled="true"]):hover) {
    border-color: var(--accent-color);
    background: rgba(var(--accent-rgb), 0.06);
}

/* An online tile opens from a layer over all of it; its pencil, globe and remove sit above. */
#hid-webapp .device-tile-open {
    position: absolute;
    inset: 0;
    padding: 0;
    border-radius: inherit;
    background: transparent;
}

#hid-webapp .device-tile-open:hover,
#hid-webapp .device-tile-open:active {
    filter: none;
    transform: none;
}

#hid-webapp .device-tile-open[aria-disabled="true"] {
    cursor: default;
}

#hid-webapp .device-tile-image {
    flex-shrink: 0;
    width: 6.6rem;
    height: 6.6rem;
    object-fit: contain;
    margin-bottom: 0.28rem;
}

#hid-webapp .device-tile.away .device-tile-image {
    opacity: 0.7;
    filter: grayscale(1);
}

#hid-webapp.dark-mode .device-tile.away .device-tile-image {
    opacity: 0.45;
}

/* Its dark picture would look see-through faded, so only greyscale marks it offline. */
#hid-webapp .device-tile.away[data-product="Titan-2"] .device-tile-image {
    opacity: 1;
}

/* One line each; longer text ends in an ellipsis. */
#hid-webapp .device-tile-name,
#hid-webapp .device-tile-id,
#hid-webapp .device-tile-label,
#hid-webapp .device-tile-status {
    flex-shrink: 0;
    max-width: 100%;
    height: 1.3em;
    line-height: 1.3;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

#hid-webapp .device-tile-name {
    font-family: "Orbitron", "Orbitron Fallback", sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
}

/* The user's name for the mouse, else its Wireless ID, and the pencil that edits it. Full
   width, so the room beside the pencil is the same whatever the name. */
#hid-webapp .device-tile-id {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    width: 100%;
    font-size: 0.88rem;
    color: var(--text-muted);
}

#hid-webapp .device-tile-label {
    min-width: 0;
}

#hid-webapp .device-tile-rename,
#hid-webapp .device-tile-name-field {
    position: relative;
    z-index: 1;
}

#hid-webapp .device-tile-rename {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 1.3em;
    height: 1.3em;
    padding: 0;
    border-radius: 0.3rem;
    background: transparent;
    color: inherit;
    font-size: inherit;
}

#hid-webapp .device-tile-rename:disabled {
    visibility: hidden;
}

#hid-webapp .device-tile-rename:hover {
    filter: none;
    transform: none;
    color: var(--accent-color);
}

#hid-webapp .device-tile-rename svg {
    width: 0.95em;
    height: 0.95em;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

#hid-webapp .device-tile-name-field {
    box-sizing: border-box;
    width: 100%;
    height: 100%;
    padding: 0 0.3rem;
    border: 1px solid var(--accent-color);
    border-radius: 0.3rem;
    background: var(--surface-input);
    color: var(--text-primary);
    font: inherit;
    text-align: center;
}

/* Its accent border shows the focus; an outline would be cut by the one-line row. */
#hid-webapp .device-tile-name-field:focus {
    outline: none;
}

#hid-webapp .device-tile-status {
    font-size: 0.94rem;
    color: var(--text-secondary);
}

#hid-webapp .device-tile:not(.away) .device-tile-status::before {
    content: "";
    display: inline-block;
    width: 0.6rem;
    height: 0.6rem;
    margin-right: 0.44rem;
    border-radius: 50%;
    vertical-align: 0.05em;
    background: #4ade80;
    box-shadow: 0 0 6px rgba(74, 222, 128, 0.5);
}

#hid-webapp .device-tile-remove {
    position: absolute;
    z-index: 1;
    top: 0.44rem;
    right: 0.44rem;
    width: 1.93rem;
    height: 1.93rem;
    padding: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--text-muted);
    font-size: 1.21rem;
    line-height: 1;
}

#hid-webapp .device-tile-remove:hover:not(:disabled) {
    filter: none;
    transform: none;
    background: rgba(0, 0, 0, 0.08);
    color: var(--text-primary);
}

#hid-webapp.dark-mode .device-tile-remove:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.1);
}

/* The product's website, opposite the remove button. */
#hid-webapp .device-tile-site {
    position: absolute;
    z-index: 1;
    top: 0.44rem;
    left: 0.44rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.93rem;
    height: 1.93rem;
    border-radius: 50%;
    color: var(--text-muted);
    text-decoration: none;
    transition:
        background-color 0.2s ease,
        color 0.2s ease;
}

#hid-webapp .device-tile-site svg {
    width: 1.05rem;
    height: 1.05rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
}

#hid-webapp .device-tile-site:hover {
    background: rgba(0, 0, 0, 0.08);
    color: var(--accent-color);
}

#hid-webapp.dark-mode .device-tile-site:hover {
    background: rgba(255, 255, 255, 0.1);
}

#hid-webapp .device-tile-remove:disabled {
    visibility: hidden;
}

#hid-webapp #mouse-tester-btn {
    position: absolute;
    top: 3.5rem;
    right: 1rem;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.85rem;
    border: 2px solid var(--accent-color);
    border-radius: 999px;
    background: transparent;
    color: var(--accent-color);
    font-weight: 600;
    font-size: 0.85rem;
    text-decoration: none;
    cursor: pointer;
    transition:
        background-color 0.3s ease,
        color 0.3s ease,
        transform 0.3s ease;
}

#hid-webapp #mouse-tester-btn.hide {
    visibility: hidden;
}

#hid-webapp #mouse-tester-btn:hover {
    background-color: var(--accent-color);
    color: #fff;
    transform: translateY(-2px) scale(1.05);
}

#hid-webapp #mouse-tester-btn:active {
    transform: translateY(1px) scale(0.98);
}

#hid-webapp .mouse-tester-icon {
    width: 1.1em;
    height: 1.1em;
    flex-shrink: 0;
}

#hid-webapp .battery-indicator {
    position: absolute;
    top: 1rem;
    left: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.6s ease;
    cursor: default;
}

#hid-webapp .battery-tooltip {
    position: absolute;
    top: calc(100% + 0.375rem);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.75);
    color: #fff;
    font-size: 0.75rem;
    padding: 0.1875rem 0.4375rem;
    border-radius: 0.375rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

#hid-webapp .battery-indicator:hover .battery-tooltip {
    opacity: 1;
}

#hid-webapp .battery-indicator.show {
    opacity: 1;
    pointer-events: auto;
}

#hid-webapp .battery-icon {
    width: 2rem;
    height: 1rem;
    border: 2px solid var(--text-muted);
    border-radius: 3px;
    position: relative;
    display: flex;
    align-items: center;
    padding: 2px;
}

#hid-webapp .battery-charge-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.8rem;
    color: #3b82f6;
    display: none;
    pointer-events: none;
}

#hid-webapp .battery-charge-icon.charging {
    display: block;
    animation: blink 1s infinite;
}

@keyframes blink {
    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }
}

#hid-webapp .battery-tip {
    position: absolute;
    right: -0.25rem;
    top: 50%;
    transform: translateY(-50%);
    width: 0.1875rem;
    height: 0.5rem;
    background-color: var(--text-muted);
    border-radius: 0 2px 2px 0;
}

#hid-webapp .battery-bars {
    display: flex;
    gap: 2px;
    align-items: center;
    height: 100%;
    width: 100%;
}

#hid-webapp .battery-bar {
    flex: 1;
    height: 100%;
    background-color: #e5e7eb;
    border-radius: 1px;
    transition: background-color 0.3s ease;
}

#hid-webapp.dark-mode .battery-bar {
    background-color: #374151;
}

#hid-webapp .battery-bar.active.low {
    background-color: #ef4444;
}

#hid-webapp .battery-bar.active.high {
    background-color: #4ade80;
}

/* Centred on the battery icon and shown whenever the battery is. */
#hid-webapp .power-off-btn {
    position: absolute;
    top: 0.875rem;
    left: 4.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    padding: 0;
    background-color: var(--accent-color);
    border: none;
    border-radius: 0.375rem;
    color: #fff;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition:
        opacity 0.6s ease,
        visibility 0.6s,
        background-color 0.3s ease,
        transform 0.15s ease;
    box-shadow: 0 2px 8px rgba(var(--accent-rgb), 0.3);
}

#hid-webapp .battery-indicator.show ~ .power-off-btn {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

#hid-webapp.safe-mode .power-off-btn {
    display: none;
}

#hid-webapp .power-off-btn:hover {
    background-color: #c0392b;
}

#hid-webapp .power-off-btn:active {
    transform: scale(0.94);
}

#hid-webapp .power-off-btn svg {
    width: 1rem;
    height: 1rem;
    display: block;
}

#hid-webapp .power-off-status {
    position: absolute;
    top: 0.875rem;
    left: 6.5rem;
    margin: 0;
    font-size: 0.85rem;
    line-height: 1.75rem;
    color: var(--text-muted);
}

#hid-webapp .power-off-status.failed {
    color: #ef4444;
}

/* Top right, on the battery's row and at its inset; above tab content, below modals. */
#hid-webapp .options-group {
    position: absolute;
    top: 0.875rem;
    right: 1rem;
    height: 1.75rem;
    display: flex;
    align-items: center;
    gap: 0.625rem;
    z-index: 200;
    text-align: left;
}

#hid-webapp .advanced-badge {
    display: none;
    align-items: center;
    height: 1.25rem;
    padding: 0 0.5rem;
    border-radius: 999px;
    background: var(--accent-color);
    color: #fff;
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.1em;
}

#hid-webapp .advanced-badge.show {
    display: inline-flex;
}

#hid-webapp .options-svg {
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Undoes the global pill button. */
#hid-webapp .options-btn,
#hid-webapp .theme-segment,
#hid-webapp .options-reset-btn {
    font: inherit;
    font-size: 0.8125rem;
    color: var(--text-primary);
    background: transparent;
    border: 0;
    transition: none;
}

#hid-webapp .options-btn:hover,
#hid-webapp .options-btn:active,
#hid-webapp .theme-segment:hover,
#hid-webapp .theme-segment:active,
#hid-webapp .options-reset-btn:hover,
#hid-webapp .options-reset-btn:active {
    transform: none;
    filter: none;
}

#hid-webapp .options-btn:focus-visible,
#hid-webapp .theme-segment:focus-visible,
#hid-webapp .options-reset-btn:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

#hid-webapp .options-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    height: 1.75rem;
    padding: 0 0.5rem 0 0.625rem;
    border: 1px solid var(--menu-border);
    border-radius: 0.375rem;
}

#hid-webapp .options-btn .options-svg {
    width: 0.875rem;
    height: 0.875rem;
}

#hid-webapp .options-btn:hover,
#hid-webapp .options-btn[aria-expanded="true"] {
    background: var(--menu-hover);
}

#hid-webapp .options-btn[aria-expanded="true"] {
    border-color: var(--menu-border-open);
}

#hid-webapp .options-chevron {
    transition: transform 120ms cubic-bezier(0.2, 0.7, 0.2, 1);
}

#hid-webapp .options-btn[aria-expanded="true"] .options-chevron {
    transform: rotate(180deg);
}

#hid-webapp .options-menu {
    position: absolute;
    top: calc(100% + 0.4375rem);
    right: 0;
    width: min(17.25rem, calc(100vw - 4rem));
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    padding: 0.375rem;
    background: var(--menu-bg);
    border: 1px solid var(--menu-border);
    border-radius: 0.625rem;
    box-shadow: var(--shadow-menu);
    color: var(--text-primary);
    font-size: 0.8125rem;
    outline: none;
}

#hid-webapp .options-menu[hidden] {
    display: none;
}

#hid-webapp .options-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 2.625rem;
    padding: 0 0.5rem;
}

#hid-webapp .theme-segmented {
    display: flex;
    padding: 0.125rem;
    border-radius: 0.4375rem;
    background: var(--menu-well);
}

#hid-webapp .theme-segment {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    height: 1.625rem;
    padding: 0 0.5625rem;
    border-radius: 0.3125rem;
    color: var(--menu-muted);
    font-size: 0.75rem;
}

#hid-webapp .theme-segment .options-svg {
    width: 0.8125rem;
    height: 0.8125rem;
}

#hid-webapp .theme-segment[aria-pressed="true"] {
    background: var(--menu-segment);
    color: var(--menu-segment-text);
}

/* Only once a device is connected (advanced-mode.js sets show). */
#hid-webapp .options-menu .advanced-mode-switch:not(.show) {
    display: none;
}

#hid-webapp .advanced-mode-switch.firmware-gated {
    opacity: 0.4;
    cursor: not-allowed;
}

#hid-webapp .advanced-mode-switch.firmware-gated .advanced-mode-toggle {
    pointer-events: none;
}

#hid-webapp .advanced-mode-switch.firmware-gated .label-text::after {
    content: " \1F512";
    font-size: 0.8em;
}

#hid-webapp .options-menu .advanced-mode-toggle {
    --track-off: var(--menu-track-off);
    width: 2.5rem;
    height: 1.375rem;
}

#hid-webapp .options-menu .advanced-mode-toggle .knob {
    top: 0.125rem;
    left: 0.125rem;
    width: 1.125rem;
    height: 1.125rem;
    transition: transform 120ms cubic-bezier(0.2, 0.7, 0.2, 1);
}

#hid-webapp .options-menu .advanced-mode-toggle input:checked ~ .knob {
    transform: translateX(1.125rem);
}

/* Reset shows with the settings (settings/index.js), at once rather than fading. */
#hid-webapp .options-menu .settings-container {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    height: auto;
    overflow: visible;
    transition: none;
}

#hid-webapp .options-menu .settings-container:not(.show) {
    display: none;
}

#hid-webapp .options-divider {
    height: 1px;
    margin: 0.25rem 0;
    background: var(--menu-border);
}

#hid-webapp .options-reset-btn {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    width: 100%;
    padding: 0.5rem;
    border-radius: 0.375rem;
    text-align: left;
}

#hid-webapp .options-reset-btn:hover {
    background: var(--menu-hover);
}

#hid-webapp .options-reset-btn .options-svg {
    width: 0.9375rem;
    height: 0.9375rem;
}

#hid-webapp .options-reset-text {
    display: flex;
    flex-direction: column;
    gap: 0.1875rem;
}

#hid-webapp .options-reset-note {
    font-size: 0.6875rem;
    color: var(--menu-muted);
}

#hid-webapp .reset-defaults-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0.5rem;
    background-color: var(--accent-color);
    border: none;
    border-radius: 999px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(var(--accent-rgb), 0.3);
}

#hid-webapp .reset-defaults-btn:hover {
    background-color: #c0392b;
}

#hid-webapp .tab-content {
    display: none;
}

#hid-webapp .tab-content.active {
    display: block;
    animation: fadeInTab 0.4s ease;
}

@keyframes fadeInTab {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#hid-webapp .settings-container {
    opacity: 0;
    visibility: hidden;
    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 .settings-container.show {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    height: auto;
    overflow: visible;
}

#hid-webapp .config-section {
    max-width: 37.5rem;
    margin: 0 auto;
    text-align: left;
    opacity: 0;
    height: 0;
    overflow: hidden;
    transform: translateY(20px);
    pointer-events: none;
    transition:
        opacity 0.6s ease,
        transform 0.6s ease,
        height 0.6s ease;
}

#hid-webapp .config-section.show {
    opacity: 1;
    height: auto;
    overflow: visible;
    transform: translateY(0);
    pointer-events: auto;
}

/* Three columns keep the heading centred next to the Linux banner. */
#hid-webapp .header-area {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    margin-bottom: 0;
}

#hid-webapp .header-area-main {
    display: flex;
    flex-direction: column;
    align-items: center;
    grid-column: 2;
}

#hid-webapp .linux-setup-banner {
    grid-column: 1;
    justify-self: start;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.6rem;
    background-color: rgba(234, 179, 8, 0.12);
    border: 1px solid rgba(234, 179, 8, 0.45);
    border-radius: 0.625rem;
    padding: 0.85rem 1rem;
    font-size: 0.85rem;
    line-height: 1.45;
    max-width: 12.5rem;
    flex-shrink: 0;
    text-align: left;
    opacity: 1;
    max-height: 300px;
    overflow: hidden;
    transition:
        opacity 0.4s ease,
        visibility 0.4s,
        max-height 0.4s ease,
        padding 0.4s ease,
        border-width 0.4s ease,
        margin 0.4s ease;
}

#hid-webapp .linux-setup-banner.banner-hidden {
    opacity: 0;
    visibility: hidden;
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    border-width: 0;
    pointer-events: none;
}

#hid-webapp .linux-setup-icon {
    font-size: 1rem;
    line-height: 1;
}

#hid-webapp .linux-setup-text {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

#hid-webapp .linux-setup-text strong {
    font-size: 0.88rem;
}

#hid-webapp .linux-setup-download {
    display: inline-block;
    padding: 0.45rem 0.9rem;
    border-radius: 999px;
    background-color: var(--accent-color);
    color: #fff;
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
    transition: opacity 0.2s ease;
    align-self: flex-start;
    border: none;
    cursor: pointer;
    font-family: inherit;
}

#hid-webapp .linux-setup-download:hover {
    opacity: 0.85;
}

@media (max-width: 800px) and (pointer: coarse) {
    #hid-webapp .sidebar-col {
        position: static;
        height: auto;
    }

    #hid-webapp .main-content {
        max-width: 100%;
        width: 100%;
        margin: 0;
        padding: 0 1rem;
    }

    #hid-webapp .container {
        padding: 2rem 1.5rem;
        margin: 2rem 0;
    }

    #hid-webapp .heading-row h1 {
        margin-bottom: 2rem;
    }

    #hid-webapp .top-bar {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }

    #hid-webapp .sidebar {
        display: none;
    }

    #hid-webapp .battery-indicator {
        position: static;
        margin: 1rem auto;
        justify-content: center;
    }

    #hid-webapp .power-off-btn {
        position: static;
        margin: 0.5rem auto;
    }

    #hid-webapp .power-off-status {
        position: static;
        text-align: center;
    }

    /* The Options controls keep their own size against the full-width phone buttons. */
    #hid-webapp .options-btn {
        width: auto !important;
        padding: 0 0.5rem 0 0.625rem !important;
        font-size: 0.8125rem !important;
    }

    #hid-webapp .theme-segment {
        width: auto !important;
        padding: 0 0.5625rem !important;
        font-size: 0.75rem !important;
    }

    #hid-webapp .options-reset-btn {
        padding: 0.5rem !important;
        font-size: 0.8125rem !important;
    }
}

/* ui-scale.js sets this while it changes rem, so rem-sized controls resize at once. */
.rescaling *,
.rescaling *::before,
.rescaling *::after {
    transition-duration: 0s !important;
    transition-delay: 0s !important;
}
