/* Mystira surface layout.
   Owns the layout and component structure the PWA used to take from Bootstrap.
   Colors come from brand.css tokens. Load this before brand.css and app.css. */

*,
*::before,
*::after {
  box-sizing: border-box;
}

h1, h2, h3, h4, h5, h6 {
  margin-top: 0;
  margin-bottom: 0.5rem;
  line-height: 1.2;
}

p {
  margin-top: 0;
  margin-bottom: 1rem;
}

ul, ol {
  padding-left: 2rem;
  margin-top: 0;
  margin-bottom: 1rem;
}

button,
input,
optgroup,
select,
textarea {
  margin: 0;
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
}

img {
  vertical-align: middle;
}

/* Spacing. Scale matches the values already in markup: 0, .25, .5, 1, 1.5, 3rem. */
.m-0 { margin: 0 !important; }
.m-1 { margin: 0.25rem !important; }
.m-2 { margin: 0.5rem !important; }
.m-3 { margin: 1rem !important; }
.m-4 { margin: 1.5rem !important; }
.m-5 { margin: 3rem !important; }
.m-auto { margin: auto !important; }
.mx-0 { margin-left: 0 !important; margin-right: 0 !important; }
.mx-1 { margin-left: 0.25rem !important; margin-right: 0.25rem !important; }
.mx-2 { margin-left: 0.5rem !important; margin-right: 0.5rem !important; }
.mx-3 { margin-left: 1rem !important; margin-right: 1rem !important; }
.mx-4 { margin-left: 1.5rem !important; margin-right: 1.5rem !important; }
.mx-5 { margin-left: 3rem !important; margin-right: 3rem !important; }
.mx-auto { margin-left: auto !important; margin-right: auto !important; }
.my-0 { margin-top: 0 !important; margin-bottom: 0 !important; }
.my-1 { margin-top: 0.25rem !important; margin-bottom: 0.25rem !important; }
.my-2 { margin-top: 0.5rem !important; margin-bottom: 0.5rem !important; }
.my-3 { margin-top: 1rem !important; margin-bottom: 1rem !important; }
.my-4 { margin-top: 1.5rem !important; margin-bottom: 1.5rem !important; }
.my-5 { margin-top: 3rem !important; margin-bottom: 3rem !important; }
.my-auto { margin-top: auto !important; margin-bottom: auto !important; }
.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: 0.25rem !important; }
.mt-2 { margin-top: 0.5rem !important; }
.mt-3 { margin-top: 1rem !important; }
.mt-4 { margin-top: 1.5rem !important; }
.mt-5 { margin-top: 3rem !important; }
.mt-auto { margin-top: auto !important; }
.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 0.25rem !important; }
.mb-2 { margin-bottom: 0.5rem !important; }
.mb-3 { margin-bottom: 1rem !important; }
.mb-4 { margin-bottom: 1.5rem !important; }
.mb-5 { margin-bottom: 3rem !important; }
.mb-auto { margin-bottom: auto !important; }
.ms-0 { margin-left: 0 !important; }
.ms-1 { margin-left: 0.25rem !important; }
.ms-2 { margin-left: 0.5rem !important; }
.ms-3 { margin-left: 1rem !important; }
.ms-4 { margin-left: 1.5rem !important; }
.ms-5 { margin-left: 3rem !important; }
.ms-auto { margin-left: auto !important; }
.me-0 { margin-right: 0 !important; }
.me-1 { margin-right: 0.25rem !important; }
.me-2 { margin-right: 0.5rem !important; }
.me-3 { margin-right: 1rem !important; }
.me-4 { margin-right: 1.5rem !important; }
.me-5 { margin-right: 3rem !important; }
.me-auto { margin-right: auto !important; }
.p-0 { padding: 0 !important; }
.p-1 { padding: 0.25rem !important; }
.p-2 { padding: 0.5rem !important; }
.p-3 { padding: 1rem !important; }
.p-4 { padding: 1.5rem !important; }
.p-5 { padding: 3rem !important; }
.px-0 { padding-left: 0 !important; padding-right: 0 !important; }
.px-1 { padding-left: 0.25rem !important; padding-right: 0.25rem !important; }
.px-2 { padding-left: 0.5rem !important; padding-right: 0.5rem !important; }
.px-3 { padding-left: 1rem !important; padding-right: 1rem !important; }
.px-4 { padding-left: 1.5rem !important; padding-right: 1.5rem !important; }
.px-5 { padding-left: 3rem !important; padding-right: 3rem !important; }
.py-0 { padding-top: 0 !important; padding-bottom: 0 !important; }
.py-1 { padding-top: 0.25rem !important; padding-bottom: 0.25rem !important; }
.py-2 { padding-top: 0.5rem !important; padding-bottom: 0.5rem !important; }
.py-3 { padding-top: 1rem !important; padding-bottom: 1rem !important; }
.py-4 { padding-top: 1.5rem !important; padding-bottom: 1.5rem !important; }
.py-5 { padding-top: 3rem !important; padding-bottom: 3rem !important; }
.pt-0 { padding-top: 0 !important; }
.pt-1 { padding-top: 0.25rem !important; }
.pt-2 { padding-top: 0.5rem !important; }
.pt-3 { padding-top: 1rem !important; }
.pt-4 { padding-top: 1.5rem !important; }
.pt-5 { padding-top: 3rem !important; }
.pb-0 { padding-bottom: 0 !important; }
.pb-1 { padding-bottom: 0.25rem !important; }
.pb-2 { padding-bottom: 0.5rem !important; }
.pb-3 { padding-bottom: 1rem !important; }
.pb-4 { padding-bottom: 1.5rem !important; }
.pb-5 { padding-bottom: 3rem !important; }
.ps-0 { padding-left: 0 !important; }
.ps-1 { padding-left: 0.25rem !important; }
.ps-2 { padding-left: 0.5rem !important; }
.ps-3 { padding-left: 1rem !important; }
.ps-4 { padding-left: 1.5rem !important; }
.ps-5 { padding-left: 3rem !important; }
.pe-0 { padding-right: 0 !important; }
.pe-1 { padding-right: 0.25rem !important; }
.pe-2 { padding-right: 0.5rem !important; }
.pe-3 { padding-right: 1rem !important; }
.pe-4 { padding-right: 1.5rem !important; }
.pe-5 { padding-right: 3rem !important; }

@media (min-width: 768px) {
  .me-md-2 { margin-right: 0.5rem !important; }
}

/* Display and flex */
.d-none { display: none !important; }
.d-inline { display: inline !important; }
.d-inline-block { display: inline-block !important; }
.d-block { display: block !important; }
.d-flex { display: flex !important; }
.d-inline-flex { display: inline-flex !important; }
.d-grid { display: grid !important; }

.flex-row { flex-direction: row !important; }
.flex-column { flex-direction: column !important; }
.flex-wrap { flex-wrap: wrap !important; }
.flex-nowrap { flex-wrap: nowrap !important; }
.flex-grow-1 { flex-grow: 1 !important; }
.flex-shrink-0 { flex-shrink: 0 !important; }
.justify-content-start { justify-content: flex-start !important; }
.justify-content-center { justify-content: center !important; }
.justify-content-end { justify-content: flex-end !important; }
.justify-content-between { justify-content: space-between !important; }
.align-items-start { align-items: flex-start !important; }
.align-items-center { align-items: center !important; }
.align-items-end { align-items: flex-end !important; }
.align-self-center { align-self: center !important; }
.gap-1 { gap: 0.25rem !important; }
.gap-2 { gap: 0.5rem !important; }
.gap-3 { gap: 1rem !important; }
.gap-4 { gap: 1.5rem !important; }
.gap-5 { gap: 3rem !important; }

@media (min-width: 576px) {
  .d-sm-none { display: none !important; }
  .d-sm-inline { display: inline !important; }
  .d-sm-block { display: block !important; }
  .d-sm-flex { display: flex !important; }
}

@media (min-width: 768px) {
  .d-md-none { display: none !important; }
  .d-md-block { display: block !important; }
  .d-md-flex { display: flex !important; }
}

@media (min-width: 992px) {
  .d-lg-none { display: none !important; }
  .d-lg-block { display: block !important; }
  .d-lg-flex { display: flex !important; }
}

@media (min-width: 1200px) {
  .d-xl-none { display: none !important; }
  .d-xl-flex { display: flex !important; }
  .d-xl-inline-flex { display: inline-flex !important; }
  .d-xl-block { display: block !important; }
}

/* Grid */
.container,
.container-fluid {
  width: 100%;
  padding-right: 0.75rem;
  padding-left: 0.75rem;
  margin-right: auto;
  margin-left: auto;
}

@media (min-width: 576px) { .container { max-width: 540px; } }
@media (min-width: 768px) { .container { max-width: 720px; } }
@media (min-width: 992px) { .container { max-width: 960px; } }
@media (min-width: 1200px) { .container { max-width: 1140px; } }
@media (min-width: 1400px) { .container { max-width: 1320px; } }

.row {
  --m-gutter-x: 1.5rem;
  --m-gutter-y: 0;
  display: flex;
  flex-wrap: wrap;
  margin-top: calc(-1 * var(--m-gutter-y));
  margin-right: calc(-0.5 * var(--m-gutter-x));
  margin-left: calc(-0.5 * var(--m-gutter-x));
}

.row > * {
  flex-shrink: 0;
  width: 100%;
  max-width: 100%;
  padding-right: calc(var(--m-gutter-x) * 0.5);
  padding-left: calc(var(--m-gutter-x) * 0.5);
  margin-top: var(--m-gutter-y);
}

.g-0 { --m-gutter-x: 0; --m-gutter-y: 0; }
.g-1 { --m-gutter-x: 0.25rem; --m-gutter-y: 0.25rem; }
.g-2 { --m-gutter-x: 0.5rem; --m-gutter-y: 0.5rem; }
.g-3 { --m-gutter-x: 1rem; --m-gutter-y: 1rem; }
.g-4 { --m-gutter-x: 1.5rem; --m-gutter-y: 1.5rem; }
.g-5 { --m-gutter-x: 3rem; --m-gutter-y: 3rem; }

.col-1 { flex: 0 0 auto; width: 8.333333%; }
.col-2 { flex: 0 0 auto; width: 16.666667%; }
.col-3 { flex: 0 0 auto; width: 25%; }
.col-4 { flex: 0 0 auto; width: 33.333333%; }
.col-5 { flex: 0 0 auto; width: 41.666667%; }
.col-6 { flex: 0 0 auto; width: 50%; }
.col-7 { flex: 0 0 auto; width: 58.333333%; }
.col-8 { flex: 0 0 auto; width: 66.666667%; }
.col-9 { flex: 0 0 auto; width: 75%; }
.col-10 { flex: 0 0 auto; width: 83.333333%; }
.col-11 { flex: 0 0 auto; width: 91.666667%; }
.col-12 { flex: 0 0 auto; width: 100%; }
.col-auto { flex: 0 0 auto; width: auto; }

@media (min-width: 576px) {
  .col-sm-1 { flex: 0 0 auto; width: 8.333333%; }
  .col-sm-2 { flex: 0 0 auto; width: 16.666667%; }
  .col-sm-3 { flex: 0 0 auto; width: 25%; }
  .col-sm-4 { flex: 0 0 auto; width: 33.333333%; }
  .col-sm-5 { flex: 0 0 auto; width: 41.666667%; }
  .col-sm-6 { flex: 0 0 auto; width: 50%; }
  .col-sm-7 { flex: 0 0 auto; width: 58.333333%; }
  .col-sm-8 { flex: 0 0 auto; width: 66.666667%; }
  .col-sm-9 { flex: 0 0 auto; width: 75%; }
  .col-sm-10 { flex: 0 0 auto; width: 83.333333%; }
  .col-sm-11 { flex: 0 0 auto; width: 91.666667%; }
  .col-sm-12 { flex: 0 0 auto; width: 100%; }
  .col-sm-auto { flex: 0 0 auto; width: auto; }
}

@media (min-width: 768px) {
  .col-md-1 { flex: 0 0 auto; width: 8.333333%; }
  .col-md-2 { flex: 0 0 auto; width: 16.666667%; }
  .col-md-3 { flex: 0 0 auto; width: 25%; }
  .col-md-4 { flex: 0 0 auto; width: 33.333333%; }
  .col-md-5 { flex: 0 0 auto; width: 41.666667%; }
  .col-md-6 { flex: 0 0 auto; width: 50%; }
  .col-md-7 { flex: 0 0 auto; width: 58.333333%; }
  .col-md-8 { flex: 0 0 auto; width: 66.666667%; }
  .col-md-9 { flex: 0 0 auto; width: 75%; }
  .col-md-10 { flex: 0 0 auto; width: 83.333333%; }
  .col-md-11 { flex: 0 0 auto; width: 91.666667%; }
  .col-md-12 { flex: 0 0 auto; width: 100%; }
  .col-md-auto { flex: 0 0 auto; width: auto; }
}

@media (min-width: 992px) {
  .col-lg-1 { flex: 0 0 auto; width: 8.333333%; }
  .col-lg-2 { flex: 0 0 auto; width: 16.666667%; }
  .col-lg-3 { flex: 0 0 auto; width: 25%; }
  .col-lg-4 { flex: 0 0 auto; width: 33.333333%; }
  .col-lg-5 { flex: 0 0 auto; width: 41.666667%; }
  .col-lg-6 { flex: 0 0 auto; width: 50%; }
  .col-lg-7 { flex: 0 0 auto; width: 58.333333%; }
  .col-lg-8 { flex: 0 0 auto; width: 66.666667%; }
  .col-lg-9 { flex: 0 0 auto; width: 75%; }
  .col-lg-10 { flex: 0 0 auto; width: 83.333333%; }
  .col-lg-11 { flex: 0 0 auto; width: 91.666667%; }
  .col-lg-12 { flex: 0 0 auto; width: 100%; }
  .col-lg-auto { flex: 0 0 auto; width: auto; }
}

@media (min-width: 1200px) {
  .col-xl-1 { flex: 0 0 auto; width: 8.333333%; }
  .col-xl-2 { flex: 0 0 auto; width: 16.666667%; }
  .col-xl-3 { flex: 0 0 auto; width: 25%; }
  .col-xl-4 { flex: 0 0 auto; width: 33.333333%; }
  .col-xl-5 { flex: 0 0 auto; width: 41.666667%; }
  .col-xl-6 { flex: 0 0 auto; width: 50%; }
  .col-xl-7 { flex: 0 0 auto; width: 58.333333%; }
  .col-xl-8 { flex: 0 0 auto; width: 66.666667%; }
  .col-xl-9 { flex: 0 0 auto; width: 75%; }
  .col-xl-10 { flex: 0 0 auto; width: 83.333333%; }
  .col-xl-11 { flex: 0 0 auto; width: 91.666667%; }
  .col-xl-12 { flex: 0 0 auto; width: 100%; }
  .col-xl-auto { flex: 0 0 auto; width: auto; }
}

.w-25 { width: 25% !important; }
.w-50 { width: 50% !important; }
.w-75 { width: 75% !important; }
.w-100 { width: 100% !important; }
.w-auto { width: auto !important; }
.h-100 { height: 100% !important; }
.h-auto { height: auto !important; }
.mw-100 { max-width: 100% !important; }
.mh-100 { max-height: 100% !important; }
.img-fluid { max-width: 100%; height: auto; }

.text-center { text-align: center !important; }
.text-start { text-align: start !important; }
.text-end { text-align: end !important; }
.text-nowrap { white-space: nowrap !important; }
.fw-normal { font-weight: 400 !important; }
.fw-semibold { font-weight: 600 !important; }
.fw-bold { font-weight: 700 !important; }
.fst-italic { font-style: italic !important; }
.small,
small { font-size: 0.875em; }
.lead { font-size: 1.25rem; font-weight: 400; }
.text-primary { color: var(--m-primary) !important; }
.text-success { color: var(--m-success) !important; }
.text-danger { color: var(--m-error) !important; }
.text-warning { color: var(--m-warning) !important; }
.text-muted { color: var(--m-text-2) !important; }
.text-dark { color: var(--m-on-accent) !important; }
.align-middle { vertical-align: middle !important; }

.bg-primary { background-color: var(--m-primary) !important; }
.bg-secondary { background-color: color-mix(in srgb, var(--m-text-2) 28%, var(--m-surface)) !important; }
.bg-success { background-color: var(--m-success) !important; }
.bg-danger { background-color: var(--m-error) !important; }
.bg-warning { background-color: var(--m-warning) !important; }
.bg-dark {
  background-color: var(--m-on-accent) !important;
  color: var(--m-on-primary);
}
.bg-transparent { background-color: transparent !important; }

.rounded { border-radius: 0.375rem !important; }
.rounded-circle { border-radius: 50% !important; }
.rounded-pill { border-radius: 999px !important; }
.shadow-sm { box-shadow: var(--m-shadow-sm) !important; }
.shadow { box-shadow: var(--m-shadow-md) !important; }
.shadow-lg { box-shadow: var(--m-shadow-lg) !important; }
.shadow-none { box-shadow: none !important; }

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Buttons. Compound selectors beat the single .btn rule in brand.css. */
.btn.btn-sm {
  padding: 0.25rem 0.5rem;
  font-size: 0.875rem;
  border-radius: 0.375rem;
}

.btn.btn-lg {
  padding: 0.5rem 1rem;
  font-size: 1.25rem;
  border-radius: 0.5rem;
}

.btn.btn-link {
  font-weight: 600;
  color: var(--m-primary);
  text-decoration: underline;
  background: transparent;
  border-color: transparent;
}

.btn.btn-outline-primary {
  color: var(--m-primary);
  border-color: var(--m-primary);
  background: transparent;
}
.btn.btn-outline-primary:hover {
  color: var(--m-on-primary);
  background: var(--m-primary);
}

.btn.btn-outline-secondary {
  color: var(--m-text);
  border-color: var(--m-border);
  background: transparent;
}
.btn.btn-outline-secondary:hover {
  background: var(--m-surface-hover);
}

.btn.btn-outline-success {
  color: var(--m-success);
  border-color: var(--m-success);
  background: transparent;
}
.btn.btn-outline-success:hover {
  color: var(--m-on-primary);
  background: var(--m-success);
}

.btn.btn-outline-danger {
  color: var(--m-error);
  border-color: var(--m-error);
  background: transparent;
}
.btn.btn-outline-danger:hover {
  color: var(--m-on-primary);
  background: var(--m-error);
}

.btn.btn-outline-warning {
  color: var(--m-warning);
  border-color: var(--m-warning);
  background: transparent;
}
.btn.btn-outline-warning:hover {
  color: var(--m-on-accent);
  background: var(--m-warning);
}

.btn.btn-outline-light {
  color: var(--m-text);
  border-color: var(--m-border);
  background: transparent;
}

.btn-close {
  box-sizing: content-box;
  width: 1em;
  height: 1em;
  padding: 0.25em;
  color: var(--m-text);
  background: transparent;
  border: 0;
  border-radius: 0.375rem;
  opacity: 0.75;
  cursor: pointer;
  line-height: 1;
  font-size: 1.25rem;
}

.btn-close::before {
  content: "\00d7";
}

.modal-header .btn-close {
  margin-left: auto;
}

.btn-close:hover { opacity: 1; }

/* Forms */
.form-label {
  display: inline-block;
  margin-bottom: 0.5rem;
}

.form-control,
.form-select {
  display: block;
  width: 100%;
  padding: 0.375rem 0.75rem;
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.5;
  color: var(--m-text);
  background-color: var(--m-surface);
  background-clip: padding-box;
  border: 1px solid var(--m-border);
  border-radius: 0.5rem;
  appearance: none;
}

.form-control-sm {
  min-height: calc(1.5em + 0.5rem + 2px);
  padding: 0.25rem 0.5rem;
  font-size: 0.875rem;
  border-radius: 0.375rem;
}

.form-text {
  margin-top: 0.25rem;
  font-size: 0.875em;
  color: var(--m-text-2);
}

.form-check {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  min-height: 1.5rem;
  margin-bottom: 0.125rem;
}

.form-check-input {
  width: 1em;
  height: 1em;
  margin-top: 0.3em;
  flex-shrink: 0;
  accent-color: var(--m-primary);
}

.form-switch .form-check-input {
  width: 2.5em;
  height: 1.35em;
  margin-top: 0.15em;
  appearance: none;
  background-color: color-mix(in srgb, var(--m-text) 18%, var(--m-surface));
  border: 1px solid var(--m-border);
  border-radius: 999px;
  position: relative;
  cursor: pointer;
}

.form-switch .form-check-input:not(.completed-switch)::after {
  content: "";
  position: absolute;
  top: 2px;
  bottom: 2px;
  left: 2px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--m-on-primary);
}

.form-switch .form-check-input:not(.completed-switch):checked {
  background-color: var(--m-primary);
  border-color: var(--m-primary);
}

.form-switch .form-check-input:not(.completed-switch):checked::after {
  left: calc(100% - 2px);
  transform: translateX(-100%);
}

.input-group {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  width: 100%;
}

.input-group > .form-control,
.input-group > .form-select {
  position: relative;
  flex: 1 1 auto;
  width: 1%;
  min-width: 0;
}

.input-group-text {
  display: flex;
  align-items: center;
  padding: 0.375rem 0.75rem;
  color: var(--m-text);
  text-align: center;
  white-space: nowrap;
  background-color: var(--m-surface);
  border: 1px solid var(--m-border);
  border-radius: 0.5rem;
}

.invalid-feedback {
  display: none;
  width: 100%;
  margin-top: 0.25rem;
  font-size: 0.875em;
  color: var(--m-error);
}

.is-invalid ~ .invalid-feedback,
.was-validated :invalid ~ .invalid-feedback {
  display: block;
}

/* Alerts, cards, badges */
.alert {
  position: relative;
  padding: 1rem 1rem;
  margin-bottom: 1rem;
  border: 1px solid var(--m-border);
  border-radius: 0.5rem;
  background: var(--m-surface);
  color: var(--m-text);
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  color: var(--m-text);
  word-wrap: break-word;
  background-color: var(--m-surface);
  background-clip: border-box;
  border: 1px solid var(--m-border);
  border-radius: 12px;
}

.card-body {
  flex: 1 1 auto;
  padding: 1rem;
  color: var(--m-text);
}

.card-title { margin-bottom: 0.5rem; color: var(--m-text); }
.card-text { margin-bottom: 0; }
.card-footer {
  padding: 0.5rem 1rem;
  background-color: transparent;
  border-top: 1px solid var(--m-border);
}

.badge {
  display: inline-block;
  padding: 0.35em 0.65em;
  font-size: 0.75em;
  font-weight: 700;
  line-height: 1;
  color: var(--m-on-primary);
  text-align: center;
  white-space: nowrap;
  vertical-align: baseline;
  border-radius: 0.375rem;
  background: var(--m-primary);
}

.badge.bg-secondary {
  color: var(--m-text);
}

.badge.bg-warning,
.badge.text-dark {
  color: var(--m-on-accent);
}

/* Modals. Several screens put the scrim and the dialog on the same element. */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: none;
  width: 100%;
  height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  outline: 0;
}

.modal.show { display: block; }

.modal-backdrop,
.modal.modal-scrim {
  background: color-mix(in srgb, var(--m-on-accent) 55%, transparent);
}

.modal-dialog {
  position: relative;
  width: auto;
  margin: 0.5rem;
  pointer-events: none;
}

.modal-dialog-centered {
  display: flex;
  align-items: center;
  min-height: calc(100% - 1rem);
}

.modal-content {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  pointer-events: auto;
  color: var(--m-text);
  background-color: var(--m-surface-elevated);
  background-clip: padding-box;
  border: 1px solid var(--m-border);
  border-radius: 16px;
  outline: 0;
}

.modal-header {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1rem;
  border-bottom: 1px solid var(--m-border);
}

.modal-title {
  margin-bottom: 0;
  line-height: 1.5;
  color: var(--m-text);
}

.modal-body {
  position: relative;
  flex: 1 1 auto;
  padding: 1rem;
  color: var(--m-text);
}

.modal-footer {
  display: flex;
  flex-wrap: wrap;
  flex-shrink: 0;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.75rem;
  border-top: 1px solid var(--m-border);
}

@media (min-width: 576px) {
  .modal-dialog {
    max-width: 500px;
    margin: 1.75rem auto;
  }

  .modal-dialog-centered { min-height: calc(100% - 3.5rem); }
  .modal-lg { max-width: 800px; }
}

/* Loading-failure diagnostic, shown before Blazor is up. */
.m-diagnostic {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: color-mix(in srgb, var(--m-on-accent) 55%, transparent);
}

.m-diagnostic-dialog {
  width: min(100%, 40rem);
  max-height: min(90vh, 40rem);
  display: flex;
  flex-direction: column;
  color: var(--m-text);
  background: var(--m-surface-elevated);
  border: 1px solid var(--m-border);
  border-radius: 16px;
  box-shadow: var(--m-shadow-lg);
}

.m-diagnostic-header,
.m-diagnostic-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem;
}

.m-diagnostic-header { border-bottom: 1px solid var(--m-border); }
.m-diagnostic-footer { justify-content: flex-end; border-top: 1px solid var(--m-border); }

.m-diagnostic-header h2 {
  margin: 0;
  font-size: 1.15rem;
}

.m-diagnostic-close {
  border: 0;
  background: transparent;
  color: var(--m-text);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.m-diagnostic-body {
  padding: 1rem;
  overflow: auto;
}

.m-diagnostic-body pre {
  max-height: 300px;
  overflow: auto;
  margin: 0;
  padding: 0.75rem;
  border-radius: 8px;
  background: var(--m-surface);
  color: var(--m-text);
  white-space: pre-wrap;
}

/* Navbar and menus */
.navbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0;
}

.navbar > .container,
.navbar > .container-fluid {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.navbar-brand {
  display: inline-flex;
  align-items: center;
  margin-right: 1rem;
  padding-top: 0.3125rem;
  padding-bottom: 0.3125rem;
  font-size: 1.25rem;
  text-decoration: none;
  white-space: nowrap;
}

.navbar-nav {
  display: flex;
  flex-direction: column;
  padding-left: 0;
  margin-bottom: 0;
  list-style: none;
  gap: 0.125rem;
}

.nav-item { display: flex; align-items: center; }

.nav-link {
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 1rem;
  color: var(--m-text);
  text-decoration: none;
}

.navbar-toggler {
  padding: 0.25rem 0.75rem;
  font-size: 1.25rem;
  line-height: 1;
  color: var(--m-text);
  background: transparent;
  border: 1px solid var(--m-border);
  border-radius: 0.375rem;
  cursor: pointer;
}

.navbar-toggler-icon {
  display: inline-block;
  width: 1.25rem;
  height: 1px;
  vertical-align: middle;
  background: currentColor;
  box-shadow: 0 -0.4rem 0 currentColor, 0 0.4rem 0 currentColor;
}

.navbar-collapse {
  flex-basis: 100%;
  flex-grow: 1;
  align-items: center;
}

.collapse:not(.show) { display: none; }
.collapse.show { display: block; }

@media (min-width: 1200px) {
  .navbar-expand-xl .navbar-nav {
    flex-direction: row;
  }

  .navbar-expand-xl .navbar-toggler {
    display: none;
  }
}

.dropdown { position: relative; }

.dropdown-toggle::after {
  display: inline-block;
  margin-left: 0.255em;
  vertical-align: 0.255em;
  content: "";
  border-top: 0.3em solid;
  border-right: 0.3em solid transparent;
  border-bottom: 0;
  border-left: 0.3em solid transparent;
}

.dropdown-menu {
  position: absolute;
  z-index: 1060;
  display: none;
  min-width: 10rem;
  padding: 0.5rem 0;
  margin: 0;
  list-style: none;
  color: var(--m-text);
  text-align: left;
  background-color: var(--m-surface-elevated);
  background-clip: padding-box;
  border: 1px solid var(--m-border);
  border-radius: 10px;
  box-shadow: var(--m-shadow-md);
}

.dropdown-menu.show { display: block; }
.dropdown-menu-end { right: 0; left: auto; }

.dropdown-item {
  display: block;
  width: 100%;
  padding: 0.25rem 1rem;
  clear: both;
  font-weight: 400;
  color: var(--m-text);
  text-align: inherit;
  text-decoration: none;
  white-space: nowrap;
  background-color: transparent;
  border: 0;
  cursor: pointer;
}

.dropdown-item:hover,
.dropdown-item:focus {
  background: var(--m-surface-hover);
}

.dropdown-header {
  display: block;
  padding: 0.5rem 1rem;
  margin-bottom: 0;
  font-size: 0.875rem;
  color: var(--m-text-2);
  white-space: nowrap;
}

.dropdown-divider {
  height: 0;
  margin: 0.5rem 0;
  overflow: hidden;
  border-top: 1px solid var(--m-border);
  opacity: 1;
}

/* Spinners */
.spinner-border {
  display: inline-block;
  width: 2rem;
  height: 2rem;
  vertical-align: -0.125em;
  border: 0.25em solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: m-surface-spin 0.75s linear infinite;
}

.spinner-border-sm {
  width: 1rem;
  height: 1rem;
  border-width: 0.2em;
}

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

@media (prefers-reduced-motion: reduce) {
  .spinner-border { animation: none; }
  .form-switch .form-check-input::after { transition: none; }
}
