html, body {
    margin: 0;
    padding: 0;
    font-family: var(--body-font);
    background-color: var(--neutral-layer-1);
    color: var(--neutral-foreground-rest);
}

/* ===== TOOLBOX PAGE ===== */
.toolbox-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.toolbox-header {
    padding: 2rem;
    border-bottom: 1px solid var(--neutral-stroke-rest);
    background-color: var(--neutral-layer-2);
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
}

.header-title-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.header-title {
    font-size: 1.75rem;
    font-weight: 700;
    margin: 0;
    flex: 1;
}

.header-description {
    margin: 0;
    color: var(--neutral-foreground-hint);
    font-size: 1rem;
    max-width: 700px;
}

/* Main */
.toolbox-main {
    flex: 1;
    padding: 2rem;
}

.cards-grid {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.tool-card {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1.5rem !important;
    border-radius: 8px !important;
}

.card-icon {
    display: flex;
    align-items: center;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
}

.card-description {
    flex: 1;
    color: var(--neutral-foreground-hint);
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.5;
}

.card-disabled {
    opacity: 0.6;
}

.card-requires-login {
    font-size: 0.8rem;
    color: var(--warning-foreground-rest, var(--neutral-foreground-hint));
    margin-top: -0.25rem;
}

.login-status-rows {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    flex: 1;
}

.login-status-row {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    font-size: 0.875rem;
    line-height: 1.4;
}

.login-status-label {
    color: var(--neutral-foreground-hint);
    flex-shrink: 0;
    min-width: 7rem;
}

.login-status-value {
    font-family: monospace;
    word-break: break-all;
}

.device-summary {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 0.5rem 0.75rem;
    border-left: 3px solid var(--accent-fill-rest);
    background: var(--neutral-layer-2);
}

.device-summary-row {
    display: flex;
    gap: 0.75rem;
    font-size: 0.875rem;
    line-height: 1.4;
}

.device-summary-label {
    color: var(--neutral-foreground-hint);
    flex-shrink: 0;
    min-width: 8rem;
}

.device-summary-value {
    font-family: monospace;
    word-break: break-all;
}

.danger-button {
    --accent-fill-rest: #d13438;
    --accent-fill-hover: #b8292d;
    --accent-fill-active: #a02226;
    --accent-foreground-rest: #ffffff;
    --accent-foreground-hover: #ffffff;
    --foreground-on-accent-rest: #ffffff;
    --foreground-on-accent-hover: #ffffff;
    --foreground-on-accent-active: #ffffff;
}

.donation-qr {
    display: flex;
    justify-content: center;
    padding: 0.5rem 0;
}

.donation-qr img {
    max-width: 150px;
    border-radius: 4px;
}

/* Footer */
.toolbox-footer {
    padding: 1.5rem 2rem;
    border-top: 1px solid var(--neutral-stroke-rest);
    background-color: var(--neutral-layer-2);
    text-align: center;
}

.footer-copyright {
    margin: 0 0 0.25rem;
    font-weight: 600;
    font-size: 0.875rem;
}

.footer-disclaimer {
    font-size: 0.75rem;
    color: var(--neutral-foreground-hint);
    max-width: 800px;
    margin: 0 auto;
}

/* ===== WIZARD (inline in toolbox-main) ===== */
.toolbox-main .fluent-wizard {
    max-width: 1200px;
    margin: 0 auto;
    min-height: 560px;
}

/* ===== WIZARD STEP CONTENT ===== */
/* No internal scrolling here: an overflow container would clip the
   absolutely positioned dropdown of a FluentSelect placed inside a step.
   The step grows instead and the page scrolls. */
.wstep {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    min-height: 100%;
    box-sizing: border-box;
}

.wstep-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

.wstep-header h2 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 600;
}

.wstep-body {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.form-fields {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* FluentSelect and FluentCombobox size their popup from the space left
   between the control and the bottom of the viewport. On a tall wizard
   the control sits low, so that computed value squashes the list into a
   scroller. Override the shadow-part with a usable cap instead. */
fluent-select::part(listbox),
fluent-combobox::part(listbox) {
    max-height: 20rem;
}

.preformatted p {
    margin: 0.15rem 0;
}

.executing-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 1.5rem;
}

/* Finish step */
.wstep-finish {
    align-items: center;
    text-align: center;
    justify-content: center;
}

/* ===== RECONNECT MODAL ===== */
#components-reconnect-modal {
    display: none;
}

#components-reconnect-modal.components-reconnect-show,
#components-reconnect-modal.components-reconnect-failed,
#components-reconnect-modal.components-reconnect-rejected {
    display: block;
}

.reconnect-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.reconnect-card {
    background: var(--neutral-layer-2);
    color: var(--neutral-foreground-rest);
    border: 1px solid var(--neutral-stroke-rest);
    border-radius: 8px;
    padding: 2rem 2.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    min-width: 280px;
    text-align: center;
    font-family: var(--body-font);
}

.reconnect-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--neutral-stroke-rest);
    border-top-color: var(--accent-fill-rest);
    border-radius: 50%;
    animation: reconnect-spin 0.75s linear infinite;
}

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

#components-reconnect-modal.components-reconnect-failed .reconnect-spinner,
#components-reconnect-modal.components-reconnect-rejected .reconnect-spinner {
    display: none;
}

.reconnect-msg {
    margin: 0;
    font-size: 0.95rem;
    display: none;
}

.reconnect-msg a {
    color: var(--accent-fill-rest);
}

#components-reconnect-modal.components-reconnect-show .reconnect-msg--connecting,
#components-reconnect-modal.components-reconnect-failed .reconnect-msg--failed,
#components-reconnect-modal.components-reconnect-rejected .reconnect-msg--rejected {
    display: block;
}

/* Error boundary */
.blazor-error-boundary {
    background: #b32121;
    padding: 1rem;
    color: white;
    border-radius: 4px;
}

.blazor-error-boundary::after {
    content: "An error has occurred."
}
