[data-bs-theme="light"] {
    --yd-body-bg: #f4f6f9;
    --yd-card-bg: #ffffff;
    --yd-grid-bg: #e9ecef;
    --yd-cell-bg: #dee2e6;
    --yd-cell-hover: #ced4da;
    --yd-label-color: #495057;
    --yd-dot-shadow: rgba(0, 0, 0, 0.25);
    color-scheme: light;
}

[data-bs-theme="dark"] {
    --yd-body-bg: #0d1117;
    --yd-card-bg: #161b22;
    --yd-grid-bg: #21262d;
    --yd-cell-bg: #30363d;
    --yd-cell-hover: #484f58;
    --yd-label-color: #8b949e;
    --yd-dot-shadow: rgba(0, 0, 0, 0.5);
    color-scheme: dark;
}

body {
    background-color: var(--yd-body-bg);
    min-height: 100vh;
    transition: background-color 0.2s ease, color 0.2s ease;
}

#theme-toggle {
    min-width: 7.5rem;
}

.seo-intro code {
    font-size: 0.85em;
}

.site-footer a {
    text-decoration: none;
}

.site-footer a:hover {
    text-decoration: underline;
}

/* Grid wrapper */
.grid-wrapper {
    overflow-x: auto;
    padding: 0.5rem 0;
}

.dot-grid {
    display: inline-grid;
    grid-template-columns: 3rem repeat(15, 2.25rem);
    grid-template-rows: 1.75rem repeat(8, 2.25rem);
    gap: 3px;
    background: var(--yd-grid-bg);
    padding: 0.75rem;
    border-radius: 0.5rem;
    user-select: none;
}

.grid-corner {
    /* empty top-left corner */
}

.grid-col-label,
.grid-row-label {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--yd-label-color);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.grid-row-label {
    justify-content: flex-end;
    padding-right: 0.35rem;
}

.grid-cell {
    width: 2.25rem;
    height: 2.25rem;
    border: none;
    border-radius: 50%;
    background: var(--yd-cell-bg);
    cursor: pointer;
    padding: 0;
    position: relative;
    transition: background-color 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}

.grid-cell:hover:not(:disabled) {
    background: var(--yd-cell-hover);
    transform: scale(1.08);
}

.grid-cell:focus-visible {
    outline: 2px solid #ffc107;
    outline-offset: 2px;
}

.grid-cell.active {
    background: #ffc107;
    box-shadow: 0 0 6px 2px var(--yd-dot-shadow), inset 0 0 4px rgba(255, 255, 255, 0.3);
}

.grid-cell.active:hover:not(:disabled) {
    background: #ffca2c;
}

.grid-cell.parity-error {
    outline: 2px solid #dc3545;
    outline-offset: 1px;
}

.grid-cell.parity-col {
    opacity: 0.85;
}

.grid-cell.parity-row {
    opacity: 0.85;
}

.grid-legend {
    font-size: 0.8125rem;
}

.grid-legend .legend-dot {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border-radius: 50%;
    background: #ffc107;
    vertical-align: middle;
    margin-right: 0.25rem;
    box-shadow: 0 0 3px rgba(0, 0, 0, 0.3);
}

.grid-legend .legend-empty {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border-radius: 50%;
    background: var(--yd-cell-bg);
    vertical-align: middle;
    margin-right: 0.25rem;
    border: 1px solid var(--yd-label-color);
}

.result-value {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 1.05rem;
    font-weight: 600;
}

.column-map-table th,
.column-map-table td {
    font-size: 0.875rem;
}

.column-map-table code {
    font-size: 0.8125rem;
}

.faq-section .accordion-button {
    font-size: 0.9375rem;
    font-weight: 500;
}

.educational-section h2 {
    font-size: 1.25rem;
}

.educational-section h3 {
    font-size: 1.05rem;
}

@media (max-width: 575.98px) {
    .dot-grid {
        grid-template-columns: 2.25rem repeat(15, 1.75rem);
        grid-template-rows: 1.5rem repeat(8, 1.75rem);
        gap: 2px;
        padding: 0.5rem;
    }

    .grid-cell {
        width: 1.75rem;
        height: 1.75rem;
    }

    .grid-col-label,
    .grid-row-label {
        font-size: 0.6rem;
    }
}
