/* Scoped to driver setup: existing workspace, palette and header stay intact. */
.rocodeDriverDialog {
    box-sizing: border-box;
    width: min(520px, calc(100vw - 32px));
    max-height: calc(100dvh - 32px);
    margin: auto;
    padding: 0;
    overflow: auto;
    border: 1px solid #aac5d5;
    border-radius: 12px;
    color: #294b61;
    background: #ecf8ff;
    font-family: var(--rocode-font-family);
    box-shadow: 2px 2px 10px rgb(0 0 0 / 19%);
}
.rocodeDriverDialog::backdrop { background: rgb(59 59 59 / 60%); }
.rocodeDriverDialog [hidden], [data-usb-drivers-open][hidden] { display: none !important; }
.rocodeDriverHeader {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid #c6dae6;
    background: #d6e9f4;
}
.rocodeDriverHeader h2 { flex: 1; margin: 0; font-size: 18px; line-height: 24px; font-weight: 700; }
.rocodeDriverIcon {
    display: block;
    width: 20px;
    height: 20px;
    flex: 0 0 20px;
    background: var(--rocode-action);
    mask: url('../assets/controls/usb.svg') center / contain no-repeat;
}
.rocodeDriverClose {
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: 4px;
    color: #587184;
    background: transparent;
    font-size: 24px;
    line-height: 32px;
    cursor: pointer;
}
.rocodeDriverClose:hover { color: var(--rocode-action); background: #fff; }
.rocodeDriverBody { padding: 20px; }
.rocodeDriverBody h3 { margin: 0 0 16px; font-size: 16px; line-height: 24px; font-weight: 600; text-align: center; }
.rocodeDriverChoices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.rocodeDriverCard {
    display: grid;
    align-content: start;
    gap: 12px;
    min-width: 0;
    padding: 12px;
    border: 1px solid #c6dae6;
    border-radius: 4px;
    color: #294b61;
    background: #fff;
    font-size: 14px;
    font-weight: 600;
    line-height: 20px;
    cursor: pointer;
}
.rocodeDriverCard:hover { border-color: var(--rocode-action); background: var(--rocode-action-soft); }
.rocodeDriverCard:active { border-color: var(--rocode-action-pressed); background: #e1ebff; }
.rocodeDriverCard img { width: 100%; height: auto; aspect-ratio: 3410 / 3034; object-fit: contain; pointer-events: none; }
.rocodeDriverDetail { text-align: center; }
.rocodeDriverDetail > img { display: block; width: 184px; max-width: 70%; margin: 0 auto 16px; }
.rocodeDriverStatus { margin: 0; font-size: 14px; line-height: 20px; overflow-wrap: anywhere; }
.rocodeDriverStatus[data-state='installing']::before {
    display: block; width: 18px; height: 18px; margin: 0 auto 12px;
    border: 2px solid #c6dae6; border-top-color: var(--rocode-action); border-radius: 50%;
    content: ''; animation: rocodeDriverSpin 900ms linear infinite;
}
@keyframes rocodeDriverSpin { to { transform: rotate(360deg); } }
.rocodeDriverStatus[data-state='ready'], .rocodeDriverStatus[data-state='installed'] { color: #226644; }
.rocodeDriverStatus[data-state='failed'], .rocodeDriverStatus[data-state='not_ready'],
.rocodeDriverStatus[data-state='unavailable'] { color: #a92f2f; }
.rocodeDriverTerms { margin-top: 16px; text-align: start; font-size: 12px; line-height: 20px; }
.rocodeDriverTerms summary { padding: 4px 0; color: #2854c7; cursor: pointer; }
.rocodeDriverTerms pre { max-height: 140px; margin: 8px 0; padding: 12px; overflow: auto; white-space: pre-wrap; font: inherit; background: #fff; border: 1px solid #c6dae6; border-radius: 4px; }
.rocodeDriverTerms label { display: flex; align-items: center; gap: 8px; min-height: 36px; cursor: pointer; }
.rocodeDriverTerms input { appearance: auto; width: 16px; height: 16px; margin: 0; flex: 0 0 16px; accent-color: var(--rocode-action); cursor: pointer; }
.rocodeDriverBrowser { text-align: start; font-size: 14px; line-height: 21px; }
.rocodeDriverBrowser ol { margin: 16px 0 12px; padding-inline-start: 24px; }
.rocodeDriverBrowser li { display: list-item; list-style: decimal; }
.rocodeDriverBrowser li + li { margin-top: 8px; }
.rocodeDriverWarning { padding: 10px; border: 1px solid #d6b563; border-radius: 4px; color: #72521e; background: #fff6dc; }
.rocodeDriverDownloadNote { margin: 12px 0 0; font-size: 12px; }
.rocodeDriverButton[data-driver-download] { display: inline-flex; align-items: center; text-align: center; text-decoration: none; }
.rocodeDriverActions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 8px; padding: 12px 20px; border-top: 1px solid #d6e9f4; background: #fff; }
.rocodeDriverActions [data-driver-back] { margin-inline-end: auto; }
/* Same 36px/4px/12px/600 treatment as Run, Add Object and Mainboard actions. */
.rocodeDriverButton {
    box-sizing: border-box;
    min-height: 36px;
    min-width: 84px;
    margin: 0;
    padding: 7px 12px;
    border: 1px solid var(--rocode-action);
    border-radius: 4px;
    color: var(--rocode-action);
    background: #fff;
    font-size: 12px;
    font-weight: 600;
    line-height: 20px;
    cursor: pointer;
    transition: background-color 120ms ease, border-color 120ms ease, transform 80ms ease;
}
.rocodeDriverPrimary { color: #fff; background: var(--rocode-action); }
.rocodeDriverButton:not(:disabled):hover { border-color: var(--rocode-action-hover); color: var(--rocode-action-hover); background: var(--rocode-action-soft); }
.rocodeDriverPrimary:not(:disabled):hover { color: #fff; background: var(--rocode-action-hover); }
.rocodeDriverButton:not(:disabled):active { border-color: var(--rocode-action-pressed); transform: translateY(1px); }
.rocodeDriverPrimary:not(:disabled):active { background: var(--rocode-action-pressed); }
.rocodeDriverButton:disabled { color: var(--rocode-disabled-text); border-color: var(--rocode-disabled-bg); background: var(--rocode-disabled-bg); cursor: default; }
.rocodeDriverButton[aria-disabled='true'] { color: var(--rocode-disabled-text); border-color: var(--rocode-disabled-bg); background: var(--rocode-disabled-bg); cursor: default; transform: none; }
.rocodeDriverDialog :is(button, input, summary, a):focus-visible { outline: 3px solid var(--rocode-focus); outline-offset: 2px; }
@media (max-width: 420px) {
    .rocodeDriverBody { padding: 16px; }
    .rocodeDriverChoices { gap: 8px; }
    .rocodeDriverCard { padding: 8px; }
    .rocodeDriverActions { padding: 12px 16px; }
}
@media (prefers-reduced-motion: reduce) {
    .rocodeDriverButton { transition: none; }
    .rocodeDriverStatus[data-state='installing']::before { animation: none; }
}
