:root {
    --bs-primary:            var(--sxi-red);
    --bs-primary-rgb:        234, 28, 45;
    --bs-secondary:          var(--sxi-grey);
    --bs-secondary-rgb:      74, 79, 85;
    --bs-success:            var(--ok);
    --bs-warning:            var(--warn);
    --bs-danger:             var(--danger);
    --bs-info:               var(--info);

    --bs-body-bg:            var(--page-bg);
    --bs-body-color:         var(--ink);
    --bs-border-color:       var(--border);
    --bs-border-radius:      var(--radius);
    --bs-border-radius-lg:   var(--radius-lg);

    --bs-font-sans-serif:    var(--font-sans);
    --bs-font-monospace:     var(--font-mono);
    --bs-body-font-family:   var(--font-sans);
    --bs-body-font-size:     var(--font-size-base);
    --bs-body-line-height:   1.5;
}

.btn-primary {
    --bs-btn-bg:                   var(--sxi-red-solid);
    --bs-btn-border-color:         var(--sxi-red-solid);
    --bs-btn-hover-bg:             var(--sxi-red-hover);
    --bs-btn-hover-border-color:   var(--sxi-red-hover);
    --bs-btn-active-bg:            var(--sxi-red-hover);
    --bs-btn-active-border-color:  var(--sxi-red-hover);
    --bs-btn-disabled-bg:          var(--sxi-red-solid);
    --bs-btn-disabled-border-color: var(--sxi-red-solid);
}

.table {
    --bs-table-color:        var(--ink);
    --bs-table-border-color: var(--border);
}

.table-mono td,
.table-mono th {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 500;
    color: var(--ink);
}

.card {
    box-shadow: none;
}

.modal-content {
    box-shadow: 0 4px 16px rgba(15, 20, 25, 0.08);
}

/* Dark mode. Bootstrap 5.3 brings its own [data-bs-theme="dark"] values, which
   the page shell switches on at the same time as [data-theme="dark"]. What it
   cannot know is that our surfaces sit ABOVE the page background rather than on
   it, so the panels below would otherwise flatten into the page. */
[data-theme="dark"] {
    --bs-emphasis-color: var(--ink);
    --bs-secondary-color: var(--text-muted);
    --bs-secondary-bg: var(--surface-alt);
    --bs-tertiary-bg: var(--surface-muted);
    --bs-heading-color: var(--ink);
    --bs-link-color: var(--info);
    --bs-link-hover-color: var(--ink);
    --bs-link-color-rgb: 96, 165, 250;
    --bs-code-color: var(--purple);
}

[data-theme="dark"] .card,
[data-theme="dark"] .list-group,
[data-theme="dark"] .accordion,
[data-theme="dark"] .modal-content,
[data-theme="dark"] .dropdown-menu,
[data-theme="dark"] .offcanvas,
[data-theme="dark"] .popover,
[data-theme="dark"] .toast {
    --bs-card-bg: var(--surface);
    --bs-list-group-bg: var(--surface);
    --bs-accordion-bg: var(--surface);
    --bs-accordion-btn-bg: var(--surface-alt);
    --bs-accordion-active-bg: var(--surface-muted);
    --bs-accordion-active-color: var(--ink);
    --bs-modal-bg: var(--surface);
    --bs-dropdown-bg: var(--surface);
    --bs-dropdown-link-color: var(--text-body);
    --bs-dropdown-link-hover-bg: var(--surface-muted);
    --bs-dropdown-link-hover-color: var(--ink);
    --bs-offcanvas-bg: var(--surface);
    --bs-popover-bg: var(--surface);
    --bs-toast-bg: var(--surface);
}

/* Inputs sit on a panel, so they read one step lighter than the page rather
   than dropping into it. Bootstrap paints them with the body background. */
[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
    background-color: var(--surface-alt);
    border-color: var(--border-strong);
    color: var(--ink);
}
[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus {
    background-color: var(--surface-alt);
    color: var(--ink);
}
[data-theme="dark"] .form-control::placeholder { color: var(--text-subtle); }
[data-theme="dark"] .form-control:disabled,
[data-theme="dark"] .form-select:disabled {
    background-color: var(--surface-muted);
    color: var(--text-muted);
}
[data-theme="dark"] .input-group-text {
    background-color: var(--surface-muted);
    border-color: var(--border-strong);
    color: var(--text-body);
}

[data-theme="dark"] .table {
    --bs-table-color: var(--text-body);
    --bs-table-bg: transparent;
    --bs-table-border-color: var(--border);
    --bs-table-striped-bg: var(--surface-alt);
    --bs-table-striped-color: var(--text-body);
    --bs-table-hover-bg: var(--surface-muted);
    --bs-table-hover-color: var(--ink);
}

/* A black drop shadow is invisible on a dark ground, so the lift comes from a
   hairline instead. */
[data-theme="dark"] .modal-content {
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.6);
    border: 1px solid var(--border-strong);
}
